Does JPA support optional persistence units and if so how do I configure that?
I do have one persistence unit which is my main database.
Then I configured another one where I just read objects from the db to do some checks. To avoid messing around with transactions on multiple datasources I set the second datasource jta="false"
.
But I like to be able to check if a second datasource was defined at all and only use it if it is there. If it is not defined I'd like to simply skip my checks.
The problem is that I can not find how to make this optional. If the second datasource is not configured I get a New missing/unsatisfied dependencies
error from the deployment scanner in Jboss when my war is deployed:
service jboss.naming.context.java.secondDatasource (missing) dependents: [service jboss.persistenceunit."de.my.war#secondDatasource"]
(Btw: I am using JBoss 7.1.0 and configured the datasources in standard.xml - if that info is of any relevance.)
Any hints?