aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate: MappedSuperclass and OneToOne Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: MappedSuperclass and OneToOne" Watch "Hibernate: MappedSuperclass and OneToOne" New topic
Author

Hibernate: MappedSuperclass and OneToOne

Steli Niculescu
Greenhorn

Joined: Jul 14, 2009
Posts: 14
I'm not a big pro with Hibernate (just started learning it this week for my job). I have a small task to do concerning the following class hierarchy, which has
to be mapped in a single table :

Expression
|
----- UnaryExpression ---- NOT
|
|
----- BinaryExpression ---- OR
|
---- AND
LE: AND derives from BinaryExpression

The only concrete classes are NOT, OR and AND.
Expression is the root of the hierarchy, so i annotated it with @Entity :


Each binary expression has two operands, so i have to put their references in the abstract class BinaryExpression, which has to be a MappedSuperclass (it won't be an actual entity) :



The AND and OR classes have only simple implementation code, no more data needed for them :


When i run the code i get the following exception :


What am i doing wrong here? I've tried tens of changes to this, including annotating Expression with @MappedSuperclass (must it be @Entity, because
it's the root of the hierarchy?), annotating the attributes instead of the getters etc.
 
jQuery in Action, 2nd edition
 
subject: Hibernate: MappedSuperclass and OneToOne