Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between <component> and <one-to-one> element in hibernate

 
Brendon Woodford
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
what is the difference between <component> and <one-to-one> element in hibernate
thanks to all
 
Mujahed Syed
Ranch Hand
Posts: 34
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess difference is the key attribute. In component there isn't any key.
 
Adam Paul ii
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brandon.

I had this question once too.
O2O entity have Its own identity

As Mujahed said In component there isn't any key. A component has no identity of its own i.e PK .


Both of them have same kind of relation but their implementation depends on the Application design

I wrote a post on Component mapping here http://akash.thegrassroots.co.in/hibernate-4-x-component-mapping-tutorial-3/

Regards
Akash
 
Ankit Dan
Ranch Hand
Posts: 47
Eclipse IDE Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java itself has no concept of composition—a class or attribute can’t be marked as a component or composition. The only difference is the object identifier: A component has no identity, hence the persistent component class requires no identifier property or identifier mapping.
Hibernate uses the term component for a user-defined class that is persisted to the same table as the owning entity, that is not the case in one-to-one mapping

Hope this helps
Ankit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic