• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Find specific object using Hibernate from the database.?  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Find specific object and load data into that Object from underlying database using Hibernate?

For e.g If I don't know object's identifier and know only object's specific attribute value. Then how to retrive that object based on that attribute value using Hibernate?

Please give the syntax.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have the object class and the id value

you can easliy load as below

session.load(obj.getClass(), id)

I did not understand what problem in your case
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find by example, or just do a regular HQL query. you should take in to account that you could get multiple results.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!