tbee wrote:


Marina Vatkina wrote:

The spec defines the following limitations of a MappedSuperclass:

2.1.9.2 Mapped Superclasses
...
A mapped superclass, unlike an entity, is not queryable and cannot be
passed as an argument to EntityManager or Query operations. A mapped superclass cannot be the target of a persistent relationship.




Correct. It is not. All relations refer to the inheriting classes. So even
if the relation is defined in the @MappedSuperclass, the result of the
relation are the actual @Entity.

How can you define relationships in the mapped superclass that are *specified* in terms of the entities?


I believe this approach is invaluable if you want to save coding time: my
reverse engineering class generates a JPA MappedSuperclass based on the
database and the actual Entity class only contains the JPA table annotation
and all business logic.

You can always change the annotation from @MappedSuperclass to an @Entity and make the class abstract.


Hibernate also has some trouble with this concept, but Toplink works fine. I
have an issue with lazy loading there, but the approach is perfect.

They might, but that would be beyond the spec and as such not a portable 
solution.


Reply via email to