use of org.apache.openejb.jee.jpa.unit.Persistence in project tomee by apache.
the class AppModule method addPersistenceModule.
public void addPersistenceModule(final PersistenceModule root) {
persistenceModules.add(root);
final Persistence persistence = root.getPersistence();
for (final PersistenceUnit unit : persistence.getPersistenceUnit()) {
txTypeByUnit.put(unit.getName(), unit.getTransactionType());
}
}
use of org.apache.openejb.jee.jpa.unit.Persistence in project tomee by apache.
the class PersistenceUnitLinkResolver method isIn.
private boolean isIn(final PersistenceUnit value, final WebModule war) {
final Collection<URL> urls = (Collection<URL>) war.getAltDDs().get(DeploymentLoader.EAR_WEBAPP_PERSISTENCE_XML_JARS);
if (urls == null || urls.isEmpty()) {
return false;
}
final Collection<String> strUrls = new ArrayList<String>();
for (final URL url : urls) {
strUrls.add(URLs.toFilePath(url));
}
for (final PersistenceModule persistenceModule : module.getPersistenceModules()) {
final Persistence persistence = persistenceModule.getPersistence();
final String rootUrl;
try {
rootUrl = URLs.toFilePath(new URL(persistenceModule.getRootUrl()));
} catch (final MalformedURLException e) {
continue;
}
for (final PersistenceUnit unit : persistence.getPersistenceUnit()) {
if (unit == value) {
if (strUrls.contains(rootUrl)) {
return true;
}
}
}
}
return false;
}
use of org.apache.openejb.jee.jpa.unit.Persistence in project tomee by apache.
the class DataSourceDefinitionGlobalJPATest method persistence.
@Module
public Persistence persistence() {
final org.apache.openejb.jee.jpa.unit.PersistenceUnit unit = new org.apache.openejb.jee.jpa.unit.PersistenceUnit("jpa-global-dsdef-unit");
unit.addClass(IdEntity.class);
unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
unit.getProperties().setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
unit.setJtaDataSource("java:app/foo");
unit.setExcludeUnlistedClasses(true);
final Persistence persistence = new Persistence(unit);
persistence.setVersion("2.0");
return persistence;
}
use of org.apache.openejb.jee.jpa.unit.Persistence in project tomee by apache.
the class BeanValidationTest method persistence.
@Module
public Persistence persistence() {
final PersistenceUnit unit = new PersistenceUnit("foo-unit");
unit.addClass(EntityToValidate.class);
unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
unit.getProperties().setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
unit.setExcludeUnlistedClasses(true);
final Persistence persistence = new Persistence(unit);
persistence.setVersion("2.0");
return persistence;
}
use of org.apache.openejb.jee.jpa.unit.Persistence in project tomee by apache.
the class ImportSqlScriptTest method persistence.
@Module
public Persistence persistence() {
final PersistenceUnit unit = new PersistenceUnit("ImportSqlScriptTest");
unit.addClass(Something.class);
unit.setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
unit.setProperty("openjpa.Log", "DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE");
unit.setExcludeUnlistedClasses(true);
final Persistence persistence = new Persistence(unit);
persistence.setVersion("2.0");
return persistence;
}
Aggregations