• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need good example of hibernate with composit key

 
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
may i know a good example of hibernet with composit key and the code.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a little tutorial I put together on the topic of Hibernate JPA and Compound Primary Keys:

Hibernate Composite Key Mapping Example



The tutorial shows several ways to do it.








-Cameron McKenzie







 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does Hibernate fully supports composite key? or we should look of some other technology? or simply use JDBC?
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good to see your post, is using JPA is a must to implement Composite key or else we can also do it with simple Hibernate?
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like JPA annotations. There is an equivalent entry in a Hibernate mapping file, if you please.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cameron Wallace McKenzie wrote:I like JPA annotations. There is an equivalent entry in a Hibernate mapping file, if you please.



but no where it is mentioned in your tutorial as to how to create .hbm.xml file for all java class may i know where can i find it?

thanks in advance,
ra.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cameron Wallace McKenzie wrote:I like JPA annotations. There is an equivalent entry in a Hibernate mapping file, if you please.



you used @@Embeddable @Id @Entity, but i do not want to use and implement the annotations and EJB. can you please let me know how to proced with plaing old hibernate(composit-key)?

many thanks in advance,
rahul.
 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I'm relatively new to Hibernate and ORM world and having absolutely zero knowledge in JPA and annotations. I did some programming in Hibernate for my learning purpose but have not really used composite keys. I'm not sure, if this thread is the right thread for that, but would like to utilize the conversation already started.

1) Is there any alternative way to declare the composite keys using mapping xmls? If so, a small example is appreciated.

2) When we say session.save(object), it returns a serializable object identity. How would this behave, when I have composite keys in the database?


THanks
Kumar
 
Right! We're on it! Let's get to work tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic