tbee wrote:
How can you define relationships in the mapped superclass that are
*specified*
in terms of the entities?
Quite simple:
@Entity
class Article extends Article2
@MappedSuperclass
class Article2
@ManyToOne
private Manufacturer; // note: not Manufacturer2!!
You can always change the annotation from @MappedSuperclass to an @Entity
and
make the class abstract.
I do not believe that will work. Aim of the game is that the class returned
by queries, etc, must be the class containing all the business logic. So
AFAIK that must be the @Entity. That class must extended a class that
contains the reversed engineered mappings.
I didn't suggest to remove the existing @Entity annotation - what I suggested
was to change the @MappedSuperclass to be an @Entity, *and* make it *abstract*.
The latter will mean that you'll never get its instances back.
They might, but that would be beyond the spec and as such not a portable
solution.
If this is beyond the spec: what is @MappedSuperclass intended for?
To share common fields between several entities without sharing the table that
they are mapped to. It's behavior is closer to that of an embeddable class and
the first version of the name that the expert group discussed had an
'embeddable' in its name (see A.4 Changes Since Public Draft "Renamed
EmbeddableSuperclass as MappedSuperclass.")
Regards,
-marina