• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update with Composite keys

 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to update rows in a table which has composite key consisting of three string columns. I know that the get() method of the session object can only take one primary key. Is there any way through which we can pass the composite key to retrieve a row for updating?
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am struck here for long. Can anyone please help me.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Composite keys in Hibernate have to be implements as classes in their own right. So either you have defined a seperate class as your composite key or your are using the class your are managing itself as its own composite key. Either way, your need to populate your composite key class with appropriate values and use Session.get(Class entityClass, Serializable id).
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. Is there any link where I can see the sample code and documentation for this?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This website covers it all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic