-
1. Re: In relation to Entity hierarchy and EntityManager's beha
fhh Apr 29, 2007 6:21 AM (in response to pyctam)I think this is a misunderstanding but it is difficult to explain.
The JOINED strategy does not directly relate to the class hierachy because the class hierachy is about classes and their relationships while the persitence api deals with instances of classes. Therefore entities cannot "share" the rows in the classes of tables they have inherited.
Maybe an example makes it easier to understand: Imagine the (abstract) class Vehicle had a property license_number that is inherited up to the Boieng 747. It is not sufficient to have one license plate number for all Vehicles (it is not a static property), so you have to have one row in the vehicle table for every vehicle.
If you want to have one entry in the parent table for all the children use ManyToOne on the "child" instead of inheritance.
Regards
Felix -
2. Re: In relation to Entity hierarchy and EntityManager's beha
pyctam Apr 29, 2007 3:26 PM (in response to pyctam)Thanks for your response Felix,
You earned me a new point of view to Entity Hierarchy in EJB3. I studied today this subject and found that JOINED strategy is an alternative way for entities annotated with @SecondaryTable or used @OneToOne relationship. You just need to derive a class from its parent and you will have an acces to all attributes from secondary table or from table with one-to-one ralationship in single entity. But I still can say nothing about differences between removing entities implemented hierarchy and @SecondaryTable or @OneToOne annotations.
--
rustam bogubaev -
3. Re: In relation to Entity hierarchy and EntityManager's beha
fhh Apr 29, 2007 4:04 PM (in response to pyctam)Yes, but you will still have a row per instance in the parent tables not per class. So same problem.
Regards
Felix