Example usage for org.hibernate.jpa.boot.internal EntityManagerFactoryBuilderImpl build

List of usage examples for org.hibernate.jpa.boot.internal EntityManagerFactoryBuilderImpl build

Introduction

In this page you can find the example usage for org.hibernate.jpa.boot.internal EntityManagerFactoryBuilderImpl build.

Prototype

@Override
    public EntityManagerFactory build() 

Source Link

Usage

From source file:com.jk.db.dataaccess.orm.hibernate.JKEntityManagerFactory.java

License:Apache License

/**
 * TODO : cache entity manager./*from  w  ww  .j av a  2  s. co m*/
 *
 * @param info
 *            the info
 * @return the entity manager factory
 */
public static EntityManagerFactory createEntityManagerFactory(PersistenceUnitInfo info) {

    // Map<String, Object> integrationSettings = new HashMap<>();
    // integrationSettings.put(AvailableSettings.INTERCEPTOR, new
    // JKCustomSessionFactoryInterceptor());

    PersistenceUnitInfoDescriptor puDescriptor = new PersistenceUnitInfoDescriptor(info);
    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            puDescriptor, null);

    EntityManagerFactory emf = entityManagerFactoryBuilder.build();
    return emf;
}

From source file:org.umbrew.hibernate.search.database.worker.backend.DatabaseBackendQueueProcessor.java

License:Open Source License

private synchronized void initializeEntityManagerFactoryHolder(MaskedProperty props) {
    if (EntityManagerFactoryHolder.getEntityManagerFactory() == null) {
        Map<String, String> settings = new HashMap<String, String>();

        for (Object key : props.keySet()) {
            String property = key.toString();
            if (property.startsWith(HIBERNATE_PREFIX)) {
                String value = props.getProperty(property).toString();
                property = property.substring(HIBERNATE_PREFIX_FIRST_PART.length());
                log.debugf("Setting property \"%s\" to \"%s\" for internal entity manager", property, value);
                settings.put(property, value);
            } else {
                log.tracef("Ignoring property \"%s\" for internal entity manager", property);
            }//w  w  w  .ja  v  a 2 s.  c  o m
        }

        putIfNotPresent(settings, "hibernate.hbm2ddl.auto", "update");
        putIfNotPresent(settings, "hibernate.show_sql", "false");
        putIfNotPresent(settings, "hibernate.format_sql", "false");
        putIfNotPresent(settings, "hibernate.dialect_resolvers", StandardDialectResolver.class.getName());
        putIfNotPresent(settings, "hibernate.transaction.jta.platform", jtaPlatform);

        ParsedPersistenceXmlDescriptor deploymentDescriptor = new ParsedPersistenceXmlDescriptor(null);
        deploymentDescriptor.addClasses(LuceneDatabaseWork.class.getName());
        deploymentDescriptor.setTransactionType(PersistenceUnitTransactionType.JTA);
        EntityManagerFactoryBuilderImpl builder = new EntityManagerFactoryBuilderImpl(deploymentDescriptor,
                settings);
        builder.buildServiceRegistry();
        EntityManagerFactoryHolder.setEntityManagerFactory(builder.build());
    }
}