I'm looking for an easy way to extend existing JPA mapping. The idea is as follows:
I have an EAR project with EJB3+JPA module which has ClassA annotated and mapped to table class_a. But I want some other module (another EJB module) to have ClassB which adds more properties to ClassA (extend?).
One way that I though about, is just to add those additional fields to the class_a table and run non-HQL queries to retrieve that data. It's not good as I have to do many things by hand: type mapping, column mapping, etc.
I've done simple check but it seems that I can't extend ClassA in the second module (by ClassB) because they use different EntityManagerFactories and some classes from the first module are not seen by the second and vice versa.
I've already seen the <jar-file> tag inside persistence.xml. I need something like that, but the use of it requires to have that file listed in the first module and it must exist (It won't skip if not found). Is there something like that, that can be put on the extending module (second one) and not the extendable one (the first)?
If there's a way to extend the JPA mapping in run-time it would be great. Is there such a way ? Is there another solution to my problem ?