Hi TopLink team,
I'm trying to fix issue 1021: VALIDATION: Disallow persisting
non-entity subclasses
Can I assume that there's a one-to-one relationship btw. entity classes
and descriptors? I.e. is the follow statement true:
Class is annotated as @Entity <=> There's a ClassDescriptor for
that class.
Based on this assumption, the attached change throws a RuntimeException
in
AbstractSession.getDescriptor(Class theClass), if the descriptor for a
class
is not found. Adding it there will also change TopLink behavior for the
non-JPA case. The exception message must still be localized, of course.
Is there any reason, why TopLink returns the superclass descriptor, if
no
descriptor for the a class can be found?
Another place to add this validation would be in EntityManagerImpl,
similar to how em.contains() is called for some JPA operations. But
that would not cover the cases were the operation is cascaded to an
instance, as the internal operation is called directly and not
through
the EM interface.
I tested the validation by trying to persist a non-entity class or a
mapped superclass instance.
What do you think?
Thanks!
-- markus.