• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve a hibernate object with composite key

 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already have a post running in the one below but this is slightly unrelated query so I have created a new thread
http://www.coderanch.com/t/514145/ORM/java/do-map-composite-primary-key


How can i retrieve the hibernate object with a composite key without using a query as above. Can I do something like.
sessionFactory.getCurrentSession().get(DepartmentMonths, 1234, 1) or maybe pass the composite key ?
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this to work.... Hope this helps someone else...

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup. That's it. You just do a load or get using the key!
 
tugce hilal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that worked for me as well. thank you
 
Nathan Ellzey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Abrahm wrote:I got this to work.... Hope this helps someone else...



I'm doing something like that and keep getting the following error, which I think has to do with the hashcode, but I'm not really sure:


HELP!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic