Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How data stored in Database

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider I am using Hibernate. I have 10 records in ArrayList.
In which format data stored in Database.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what the question means. How it's stored depends on how you've mapped the class of objects in the list.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hql queries are used to retrieve data from hibernate.


From this code i can retrieve EmployeeBean object.
How can i get username and password from database and validate it.
should i do this in DAO.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably you'd only want to select from the table where the user name and password are the same as the values on the form, no? So change your HQL. If you get a result, it means there's a user with that username and password. If you don't, there isn't, and login has failed.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this code and correct. I am new to hibernate

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would work, but is potentially *horribly* inefficient.

What I actually meant was that you should select *only* the users from the DB whose password and username match.

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-where
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually my interview asked , how you check entered username and password is correct or not.
So that am searching.can you say how to
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did, several times.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic