• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate: MappedSuperclass and OneToOne

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic