Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: MappedSuperclass and OneToOne

 
Steli Niculescu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic