• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

@IdClass and @EmbeddedId

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone tell what is the difference between @IdClass and @EmbeddedId?

Thanks in advance
 
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 Compound Primary Key Class using the @Embeddable tag:





(From this Hibernate/JPA Tutorial)

Later, a class can use that compound key:



ith the @IdClass annotation, you don't declare an instance variable of type CompoundKey, but instead, just define instance variables for each of the primary key fields. You then mark the corresponding getter tags with standard @Id annotations.



Here's a little bit more detailed explaination about mapping compound primary keys with Hibernate and JPA:

Mapping Composite Keys with the Java Persistence API (JPA)

-Cameron McKenzie



 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic