-
1. Re: Global JPA model and Persistence unit
ctomc Mar 8, 2015 6:45 PM (in response to lujop)And yet again, response will be the same.
create global module and make sure you create jandex indexes for it. and than when you are adding dependency to the global module make sure you also include indexes with it.
see [AS7-1234] Hibernate does not read/use metadata for orm.xml defined entites - JBoss Issue Tracker and
in short is it just matter of preparing your module properly and use it.
-
2. Re: Global JPA model and Persistence unit
lujop Mar 9, 2015 4:48 AM (in response to ctomc)Thanks Tomaz. I will test it. Do you know if it's supported also to have the persistence.xml in the module?
-
3. Re: Global JPA model and Persistence unit
smarlow Mar 9, 2015 10:55 AM (in response to lujop)Persistence.xml files are not deployed in global modules. To share persistence units between deployments, internal service dependencies are needed on the persistence. In other words, internal code changes are needed to accommodate this.
For example, if you have commonPU.jar deployed with the entity classes + persistence.xml, your other deployments that depend on commonPU.jar would have these dependencies set so that if commonPU.jar is redeployed, the other deployments would also restart. There is also the sharing of the commonPU.jar classes that needs to work (including the enhancing/rewriting of entity classes). The clustering of the JPA second level cache might also need work.
The global JNDI (jboss.entity.manager.factory.jndi.name/jboss.entity.manager.jndi.name) option that you mentioned, doesn't add the internal service dependency that I mentioned above. So, if the deployment that contains the persistence.xml (with jboss.entity.manager.factory.jndi.name) is undeployed, the EntityManagerFactory will no longer be available in JNDI but dependent applications will not be aware. The typical use of the global JNDI (jboss.entity.manager.factory.jndi.name/jboss.entity.manager.jndi.name) is for use within the same application (it does not setup the sharing of entity classes across deployments).
-
4. Re: Global JPA model and Persistence unit
lujop Mar 9, 2015 4:52 PM (in response to smarlow)Thanks Scott.
When you say internal code changes are needed to accomodate this, do you mean WildFly internal code changes, don't you? Or in other words, that it's not supported at the moment, is it?
-
5. Re: Global JPA model and Persistence unit
smarlow Mar 9, 2015 6:21 PM (in response to lujop)There is currently no way to setup the dependencies between deployments that you would need to share persistence units between deployments. If your just sharing classes via a global module (like you asked about originally), you don't get to share a persistence unit but there are no dependencies issues (each deployment will need its own persistence.xml).