Search in sources :

Example 6 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 HibernateConsoleRuntimeException(e);
        }
    }
    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) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Example 7 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.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) AnnotationConfiguration(org.hibernate.cfg.AnnotationConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) Ejb3Configuration(org.hibernate.ejb.Ejb3Configuration)

Aggregations

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