0

I was reading the following post to package JSF pages into jar files, which is great for including only those modules of a system that a client needs: Packaging Facelets files (templates, includes, composites) in a JAR

I'd like to do something similar with JPA entity classes. Is there a way to define entities do that the relationships are option? Perhaps even have a persistence.xml that extends another persistence.xml in another package? I only want entity classes packaged with an application if our client needs that software extension.

I guess it really comes down to optional entity relationships, which doesn't seem to be supported with JPA annotations.

I'm thinking that the only solution is to have two two versions of the same entity, one with property and one without, and including one the version I want. Blah. This is a very week point of JPA, IMO. It's issues like these that I really miss the simplicity and dynamic nature of PHP. ;)

Community
  • 1
  • 1
John Manko
  • 1,828
  • 27
  • 51

1 Answers1

0

We had a project that had a similar approach as the one you mentioned. We had the model split among several jars, each of them with its one persistence.xml. It was quite a headache, when it comes to relationships between tables in different jars. What we did is to use key's in String between entities spread among different jars, but of course that it wasn't possible to enforce the relations like you could do with a FK.

Olimpiu POP
  • 5,001
  • 4
  • 34
  • 49
  • Thanks user503413. I'm thinking I will just have to have shell entity classes. Now if I could figure out how to excluded specific entities from table creation. – John Manko Nov 13 '13 at 17:10
  • In this direction I suggest you can have abstract entities, or just have objects that are not marked @Entity – Olimpiu POP Nov 13 '13 at 20:40