Search in sources :

Example 1 with Ejb3Configuration

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);
}
Also used : Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration) Configuration(org.hibernate.cfg.Configuration) JDBCMetaDataConfiguration(org.hibernate.cfg.JDBCMetaDataConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Example 2 with Ejb3Configuration

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));
}
Also used : JPAVendorAdapter(org.wso2.carbon.bpel.b4p.coordination.dao.jpa.JPAVendorAdapter) Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Example 3 with Ejb3Configuration

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;
}
Also used : HashMap(java.util.HashMap) Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Example 4 with Ejb3Configuration

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;
}
Also used : Properties(java.util.Properties) Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Example 5 with Ejb3Configuration

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));
}
Also used : Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Aggregations

Ejb3Configuration (org.hibernate.ejb.Ejb3Configuration)7 Configuration (org.hibernate.cfg.Configuration)3 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)3 HibernateException (org.jboss.tools.hibernate.runtime.spi.HibernateException)3 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)3 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 AnnotationConfiguration (org.hibernate.cfg.AnnotationConfiguration)1 JPAVendorAdapter (org.wso2.carbon.bpel.b4p.coordination.dao.jpa.JPAVendorAdapter)1