Java Code Examples for org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder#build()

The following examples show how to use org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FastBootHibernateReactivePersistenceProvider.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public EntityManagerFactory createEntityManagerFactory(String emName, Map properties) {
    if (properties == null)
        properties = new HashMap<Object, Object>();
    try {
        // These are pre-parsed during image generation:
        final List<PersistenceUnitDescriptor> units = PersistenceUnitsHolder.getPersistenceUnitDescriptors();

        for (PersistenceUnitDescriptor unit : units) {
            //if the provider is not set, don't use it as people might want to use Hibernate ORM
            if (IMPLEMENTATION_NAME.equalsIgnoreCase(unit.getProviderClassName()) ||
                    unit.getProviderClassName() == null) {
                EntityManagerFactoryBuilder emfBuilder = getEntityManagerFactoryBuilderOrNull(emName, properties);
                EntityManagerFactory emf = emfBuilder.build();
                return emf;
            }
        }

        //not the right provider
        return null;
    } catch (PersistenceException pe) {
        throw pe;
    } catch (Exception e) {
        throw new PersistenceException("Unable to build EntityManagerFactory", e);
    }
}
 
Example 2
Source File: ReactivePersistenceProvider.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p/>
 * Note: per-spec, the values passed as {@code properties} override values found in {@code persistence.xml}
 */
@Override
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
	log.tracef( "Starting createEntityManagerFactory for persistenceUnitName %s", persistenceUnitName );
	final Map immutableProperties = immutable( properties );
	final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull( persistenceUnitName, immutableProperties );
	if ( builder == null ) {
		log.trace( "Could not obtain matching EntityManagerFactoryBuilder, returning null" );
		return null;
	}
	else {
		return builder.build();
	}
}
 
Example 3
Source File: FastBootHibernatePersistenceProvider.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
    log.tracef("Starting createEntityManagerFactory for persistenceUnitName %s", persistenceUnitName);
    final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull(persistenceUnitName,
            properties);
    if (builder == null) {
        log.trace("Could not obtain matching EntityManagerFactoryBuilder, returning null");
        return null;
    } else {
        return builder.build();
    }
}
 
Example 4
Source File: HibernatePersistenceProvider.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p/>
 * Note: per-spec, the values passed as {@code properties} override values found in {@code persistence.xml}
 */
@Override
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
	log.tracef( "Starting createEntityManagerFactory for persistenceUnitName %s", persistenceUnitName );
	final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties );
	if ( builder == null ) {
		log.trace( "Could not obtain matching EntityManagerFactoryBuilder, returning null" );
		return null;
	}
	else {
		return builder.build();
	}
}
 
Example 5
Source File: CustomHibernatePersistenceProvider.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
public EntityManagerFactory createEMF(Map properties) {
	PersistenceUnitInfo info = new RapidoidPersistenceUnitInfo(persistenceUnitName, dataSource, classLoader);
	PersistenceUnitInfoDescriptor infoDescriptor = new PersistenceUnitInfoDescriptor(info);

	CustomDescriptor customDescriptor = new CustomDescriptor(infoDescriptor, entityTypes);
	EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilder(customDescriptor, properties, classLoader);

	return builder.build();
}