use of org.hibernate.ejb.Ejb3Configuration in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newJpaConfiguration.
@Override
public IConfiguration newJpaConfiguration(String entityResolver, String persistenceUnit, Map<Object, Object> overrides) {
getUsageTracker().trackNewConfigurationEvent(HIBERNATE_VERSION);
Ejb3Configuration ejb3Configuration = new Ejb3Configuration();
if (StringHelper.isNotEmpty(entityResolver)) {
try {
Class<?> resolver = ReflectHelper.classForName(entityResolver, this.getClass());
Object object = resolver.newInstance();
ejb3Configuration.setEntityResolver((EntityResolver) object);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new HibernateException(e);
}
}
ejb3Configuration.setProperty("hibernate.validator.autoregister_listeners", "false");
ejb3Configuration.setProperty("hibernate.validator.apply_to_ddl", "false");
ejb3Configuration.configure(persistenceUnit, overrides);
Configuration configuration = ejb3Configuration.getHibernateConfiguration();
return facadeFactory.createConfiguration(configuration);
}
use of org.hibernate.ejb.Ejb3Configuration in project carbon-business-process by wso2.
the class HTCoordinationDAOConnectionFactoryImpl method init.
@Override
public void init() {
JPAVendorAdapter vendorAdapter = getJPAVendorAdapter();
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addAnnotatedClass(HTProtocolHandler.class);
this.entityManagerFactory = cfg.createEntityManagerFactory(vendorAdapter.getJpaPropertyMap(null));
}
use of org.hibernate.ejb.Ejb3Configuration in project BroadleafCommerce by BroadleafCommerce.
the class EJB3ConfigurationDaoImpl method getConfiguration.
public Ejb3Configuration getConfiguration() {
synchronized (this) {
if (configuration == null) {
Ejb3Configuration temp = new Ejb3Configuration();
String previousValue = persistenceUnitInfo.getProperties().getProperty("hibernate.hbm2ddl.auto");
persistenceUnitInfo.getProperties().setProperty("hibernate.hbm2ddl.auto", "none");
configuration = temp.configure(persistenceUnitInfo, new HashMap());
configuration.getHibernateConfiguration().buildSessionFactory();
if (previousValue != null) {
persistenceUnitInfo.getProperties().setProperty("hibernate.hbm2ddl.auto", previousValue);
}
}
}
return configuration;
}
use of org.hibernate.ejb.Ejb3Configuration in project OpenMEAP by OpenMEAP.
the class Ejb3ConfigurationFactory method create.
public Ejb3Configuration create(String persistenceUnit) {
Ejb3Configuration conf = new Ejb3Configuration();
Properties jpaProperties = new Properties();
for (PropertyAssociation property : PropertyAssociation.values()) {
String value = properties.get(property.toString());
if (StringUtils.isBlank(property.getSystemProperty()) && StringUtils.isNotBlank(value)) {
property.setSystemProperty(value);
jpaProperties.put(property.getJpaPropertyName(), value);
jpaProperties.put(property.getSystemPropertyName(), value);
}
}
// if(targetEnvironment.equals("javase")) {
// conf.addProperties(jpaProperties).configure(configuration);
// } else if(targetEnvironment.equals("javaee")) {
conf.configure(configuration, jpaProperties);
return conf;
}
use of org.hibernate.ejb.Ejb3Configuration in project carbon-business-process by wso2.
the class AttachmentMgtDAOConnectionFactoryImpl method init.
@Override
public void init() {
if (transactionManager == null) {
log.debug("Transaction-Manager is not initialized before initializing entityManager. So internal " + "transaction-manager in entity manager will be used.");
}
org.wso2.carbon.attachment.mgt.core.dao.impl.jpa.JPAVendorAdapter vendorAdapter = getJPAVendorAdapter();
// Note: It is recommended to use javax.persistence.Persistence.createEntityManagerFactory() to create
// EntityManagerFactory. But it is failing in OSGI environment. So we used Ejb3Configuration, but it is deprecated.
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addAnnotatedClass(AttachmentDAOImpl.class);
this.entityManagerFactory = cfg.createEntityManagerFactory(vendorAdapter.getJpaPropertyMap(null));
}
Aggregations