Java 类org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder 实例源码

项目:lightmare    文件:HibernatePersistenceProviderExt.java   
/**
    * {@inheritDoc}
    */
   @SuppressWarnings("rawtypes")
   @Override
   public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {

EntityManagerFactory emf;

LOG.tracef("Starting createEntityManagerFactory for persistenceUnitName %s", persistenceUnitName);
try {
    final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull(persistenceUnitName,
        properties);
    if (builder == null) {
    LOG.trace("Could not obtain matching EntityManagerFactoryBuilder, returning null");
    emf = null;
    } else {
    emf = builder.build();
    }
} catch (PersistenceException pe) {
    throw pe;
} catch (Exception ex) {
    LOG.debug("Unable to build entity manager factory", ex);
    throw new PersistenceException("Unable to build entity manager factory", ex);
}

return emf;
   }
项目:lightmare    文件:HibernatePersistenceProviderExt.java   
/**
    * Generates schema from passed persistence unit name and {@link Map} of
    * properties
    */
   @SuppressWarnings("rawtypes")
   @Override
   public boolean generateSchema(String persistenceUnitName, Map map) {
LOG.tracef("Starting generateSchema for persistenceUnitName %s", persistenceUnitName);

boolean valid;

final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull(persistenceUnitName, map);
if (builder == null) {
    LOG.trace("Could not obtain matching EntityManagerFactoryBuilder, returning false");
    valid = Boolean.FALSE;
} else {
    builder.generateSchema();
    valid = Boolean.TRUE;
}

return valid;
   }
项目:lightmare    文件:HibernatePersistenceProviderExt.java   
@Override
   @SuppressWarnings("rawtypes")
   protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName,
    Map properties, ClassLoader providedClassLoader) {

EntityManagerFactoryBuilder builder;

LOG.tracef("Attempting to obtain correct EntityManagerFactoryBuilder for persistenceUnitName : %s",
    persistenceUnitName);

final Map integration = wrap(properties);
PersistenceUnitDescriptor persistenceUnit = getPersistenceXmlDescriptor(persistenceUnitName, properties,
    providedClassLoader);
if (persistenceUnit == null) {
    LOG.debug("Found no matching persistence units");
    builder = null;
} else {
    builder = Bootstrap.getEntityManagerFactoryBuilder(persistenceUnit, integration, providedClassLoader);
}

return builder;
   }
项目:carbon    文件:HibernateConfiguration.java   
@Component
public EntityManagerFactory entityManagerFactory () {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo();
    PersistenceUnitDescriptor descriptor = new PersistenceUnitInfoDescriptor(persistenceUnitInfo);
    EntityManagerFactoryBuilder entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(descriptor, null);
    return entityManagerFactoryBuilder.build();
}
项目:persistence    文件:HibernatePersistenceProviderWithGenericDatatypeSupport.java   
/**
 * {@inheritDoc}
 */
@Override
public EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {

  LOGGER.trace("Starting createEntityManagerFactory for persistenceUnitName {}", persistenceUnitName);

  try {
    final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilderOrNull(persistenceUnitName, properties);
    if (builder == null) {
      LOGGER.trace("Could not obtain matching EntityManagerFactoryBuilder, returning null");
      return null;
    } else {
      EntityManagerFactoryImpl impl = (EntityManagerFactoryImpl) builder;
      TypeResolver typeResolver = impl.getSessionFactory().getTypeResolver();
      return builder.build();
    }
  } catch (PersistenceException pe) {
    throw pe;
  } catch (Exception e) {
    LOGGER.debug("Unable to build entity manager factory", e);
    throw new PersistenceException("Unable to build entity manager factory", e);
  }
  // EntityManagerFactory entityManagerFactory = super.createEntityManagerFactory(persistenceUnitName,
  // properties);
  // if (entityManagerFactory instanceof EntityManagerFactoryImpl) {
  // SessionFactoryImpl sessionFactory = ((EntityManagerFactoryImpl)
  // entityManagerFactory).getSessionFactory();
  // TypeResolver typeResolver = sessionFactory.getTypeResolver();
  // // typeResolver.registerTypeOverride(type, keys);
  // }
  // return entityManagerFactory;
}
项目:rapidoid    文件:CustomHibernatePersistenceProvider.java   
@Override
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, ClassLoader providedClassLoader) {

    PersistenceUnitInfo info = new RapidoidPersistenceUnitInfo(persistenceUnitName, dataSource, providedClassLoader);
    PersistenceUnitInfoDescriptor persistenceUnit = new PersistenceUnitInfoDescriptor(info);

    return emfBuilder(persistenceUnit, properties, providedClassLoader);
}
项目:rapidoid    文件:CustomHibernatePersistenceProviderTest.java   
@Test
public void testAlternativeHibernateConfigFile() {
    JdbcClient h2 = JDBC.h2("test").init();
    DataSource dataSource = h2.bootstrapDatasource();
    CustomHibernatePersistenceProvider provider = new CustomHibernatePersistenceProvider(dataSource);

    Map props = U.map("hibernate.ejb.cfgfile", "hibernate.xml");
    EntityManagerFactoryBuilder emfBuilder = provider.getEntityManagerFactoryBuilderOrNull("test", props, this.getClass().getClassLoader());
    assertNotNull(emfBuilder);
}
项目:lightmare    文件:HibernatePersistenceProviderExt.java   
/**
    * Generates schema from {@link PersistenceUnitInfo} instance
    */
   @SuppressWarnings("rawtypes")
   @Override
   public void generateSchema(PersistenceUnitInfo info, Map map) {
LOG.tracef("Starting generateSchema : PUI.name=%s", info.getPersistenceUnitName());

PersistenceUnitDescriptor descriptor = getPersistenceUnitDescriptor(info);
final EntityManagerFactoryBuilder builder = Bootstrap.getEntityManagerFactoryBuilder(descriptor, map);
builder.generateSchema();
   }
项目:lightmare    文件:HibernatePersistenceProviderExt.java   
/**
    * Gets {@link EntityManagerFactoryBuilder} for passed unit name and
    * {@link Map} of properties
    */
   @SuppressWarnings("rawtypes")
   protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName,
    Map properties) {

EntityManagerFactoryBuilder emfBuilder;

ClassLoader loader = MetaConfig.getOverridenClassLoader(metaConfig);
emfBuilder = getEntityManagerFactoryBuilderOrNull(persistenceUnitName, properties, loader);

return emfBuilder;
   }
项目:sdcct    文件:SdcctEntityManagerFactoryFactoryBean.java   
@Override
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, Map props,
    @Nullable ClassLoader classLoader) {
    return new SdcctEntityManagerFactoryBuilder(persistenceUnitDescriptor, props, classLoader);
}
项目:rapidoid    文件:CustomHibernatePersistenceProvider.java   
@Override
protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, Map integration, ClassLoader cl) {
    return emfBuilder(persistenceUnitDescriptor, integration, cl);
}
项目:rapidoid    文件:CustomHibernatePersistenceProvider.java   
private EntityManagerFactoryBuilder emfBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, Map integration, ClassLoader cl) {
    CustomDescriptor descriptor = new CustomDescriptor(persistenceUnitDescriptor, names);
    return super.getEntityManagerFactoryBuilder(descriptor, integration, cl);
}