No, they don't.
I removed all other annotations and cut the inheritance and ended up with a very simple class. Problem remained.
A thing that wasn't mentioned in my post (because I thought it wasn't relevant) was that I'm running this inside an OSGi container (Felix if that matters). Now, such a container shields different "bundles" from each other, so they can't see each other's classes until you specifically "export" packages.
The annotated classes were sitting in a different bundle than my persistence.xml and I assumed that I could just import the annotated classes from another bundle and do the persistency init stuff elsewhere. Turns out I can't, although I haven't really understood why.
So, if you're using JPA in conjunction with OSGi bundles, you have to make sure that:
- Annotated classes and persistence.xml are together in the same bundle
- this bundle exports the package containing the annotated classes
- the persistency unit(s) are listed in the bundle's manifest file
You can then do the actual persistency things (like calling EntityManager.persist) in different bundles.
As a side note, I got similarly weird errors when trying to use JAXB annotations across bundles. It seems that the JAXBContext and / or the ObjectFactory have to be instantiated in the same bundle that contains the annotated classes. I couldn't really nail this down, but putting things in the same bundle helped.
It would be great if someone with a deeper understanding of OSGi, class loading and annotations could comment on what might be happening here.
Update: exporting / importing the proper annotation packages might enable you to have persistence.xml and annotated classes in different bundles, see here. Haven't tested, though.