Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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.
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic