Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on @IdClass and @EmbeddedID

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I can understand that when we need composite primary keys, we go for @IdClass or @EmbeddedId. Under what scenario do we use either one of them? I mean using them is the same or different?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions guys?
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jothi,

One visible difference is in the way you reference them in JQL:

- In one case, IdClass, you would do something like:


- In the other one, EmbeddedId, you would:



On the other hand, I found the use of IdClass brings some other complications as you need to define each primary key attribute in both the IdClass and the Entity, taking care of using the same name and java type. This redundancy may lead to committing more errors.


In the end, both do what they are supposed to do. So, neither of them is better than the other. It is just a matter of preference.
[ September 02, 2008: Message edited by: Sergio Tridente ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic