File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes diff between MappedSuperClass and Embeddable class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "diff between MappedSuperClass and Embeddable class" Watch "diff between MappedSuperClass and Embeddable class" New topic

diff between MappedSuperClass and Embeddable class

Senthil Kumar
Ranch Hand

Joined: Mar 13, 2006
Posts: 264
can someone explain the differences between the mapped class and embeddable class
[ August 30, 2007: Message edited by: Senthil Kumar SS ]

when you really want something, all the universe always conspires in your favour.<br /> <br />SCJP1.5-77%<br />SCWCD-89%
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
You can use a MappedSuperClass between 2 Entities in an entities hierarchy.
All the subclasses of a MappedSuperClass will inherit the persistent properties of the MappedSuperClass.

Embedded classes can be used in classes of distinct hierarchies.

Hope it helps.

SCJP5 | SCBCD5 | SCEA5 Part 1
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Quoting from Spec.

Mapped Superclasses:
An entity may inherit from a superclass that provides persistent entity state and mapping information,but which is not itself an entity. Typically, the purpose of such a mapped superclass is to define state and mapping information that is common to multiple entity classes.

Quoting from Spec.2.1.5
Embeddable Classes
An entity may use other fine-grained classes to represent entity state. Instances of these classes, unlike entity instances themselves, do not have persistent identity. Instead, they exist only as embedded objects of the entity to which they belong. Such embedded objects belong strictly to their owning entity, and are not sharable across persistent entities.

Thanks and Regards
I agree. Here's the link:
subject: diff between MappedSuperClass and Embeddable class
It's not a secret anymore!