wood burning stoves*
The moose likes Object Relational Mapping and the fly likes How to map entity from inheritance hierarchy to property in another entity? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to map entity from inheritance hierarchy to property in another entity?" Watch "How to map entity from inheritance hierarchy to property in another entity?" New topic
Author

How to map entity from inheritance hierarchy to property in another entity?

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

I have entity hierarchy with inheriatnce type SINGLE_TABLE :
The problem is how to map this JuniorUser entity and all its subclasses as property in Answer entity as :

Thank you!


True person is moral, false is right!
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
You don't need to do anything special, just map it the same way you map any relationship. You can use @OneToOne or @ManyToOne.

http://en.wikibooks.org/wiki/Java_Persistence/Inheritance


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Thank yoy for reply!

You don't need to do anything special, just map it the same way you map any relationship. You can use @OneToOne or @ManyToOne.

This is true!!!
 
wood burning stoves
 
subject: How to map entity from inheritance hierarchy to property in another entity?
 
Similar Threads
Hibernate: schema export unsuccessful java.sql.SQLTransientConnectionException: java.net.ConnectExce
java.lang.NullPointerException at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValue
How to autowire type Class into constructor and instantiate bean which is superclass by super()?
Going from implements Controller to @Controller injection problem
Transaction management in Spring