Java 类org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor 实例源码

项目:owsi-core-parent    文件:InterceptorAwareHibernatePersistenceProvider.java   
/**
 * 2017-05-24 · reworked from SpringHibernateJpaPersistenceProvider so that we can inject a custom
 * {@link EntityManagerFactoryBuilderImpl}; previous implementation that overrides
 * {@link InterceptorAwareHibernatePersistenceProvider#getEntityManagerFactoryBuilder} no longer works
 * as there are several paths with various arguments and the overloaded one was no longer called.
 */
@Override
@SuppressWarnings("rawtypes")
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) {
    return new EntityManagerFactoryBuilderImpl(new PersistenceUnitInfoDescriptor(info), properties) {
        @Override
        protected void populate(SessionFactoryBuilder sfBuilder, StandardServiceRegistry ssr) {
            super.populate(sfBuilder, ssr);

            if (InterceptorAwareHibernatePersistenceProvider.this.interceptor != null) {
                LOGGER.warn("Installing our Spring managed interceptor.");
                sfBuilder.applyInterceptor(InterceptorAwareHibernatePersistenceProvider.this.interceptor);
            }
        }
    }.build();
}
项目:high-performance-java-persistence    文件:LongToNumericTypeTest.java   
@Test
public void test() {
    PersistenceUnitInfoImpl persistenceUnitInfo = new PersistenceUnitInfoImpl(
            LongToNumericTypeTest.class.getName(),
            Collections.singletonList( Event.class.getName() ),
            validateProperties()
    );

    Map<String, Object> configuration = new HashMap<>();
    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor( persistenceUnitInfo), configuration
    );
    EntityManagerFactory emf = null;
    try {
        emf = entityManagerFactoryBuilder.build();
    }
    finally {
        if ( emf != null ) {
            emf.close();
        }
    }
}
项目:hibernate-types    文件:AbstractTest.java   
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<>();
    configuration.put(AvailableSettings.INTERCEPTOR, interceptor());
    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
项目:hibernate-types    文件:AbstractTest.java   
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<String, Object>();

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
项目:hibernate-types    文件:AbstractTest.java   
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<String, Object>();
    configuration.put(AvailableSettings.INTERCEPTOR, interceptor());
    Integrator integrator = integrator();

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
项目:jk-db    文件:JKEntityManagerFactory.java   
/**
 * TODO : cache entity manager.
 *
 * @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;
}
项目:spring4-understanding    文件:SpringHibernateJpaPersistenceProvider.java   
@Override
@SuppressWarnings("rawtypes")
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) {
    final List<String> mergedClassesAndPackages = new ArrayList<String>(info.getManagedClassNames());
    if (info instanceof SmartPersistenceUnitInfo) {
        mergedClassesAndPackages.addAll(((SmartPersistenceUnitInfo) info).getManagedPackages());
    }
    return new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(info) {
                @Override
                public List<String> getManagedClassNames() {
                    return mergedClassesAndPackages;
                }
            }, properties).build();
}
项目:carbon    文件:HibernateConfiguration.java   
@Component
public EntityManagerFactory entityManagerFactory () {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo();
    PersistenceUnitDescriptor descriptor = new PersistenceUnitInfoDescriptor(persistenceUnitInfo);
    EntityManagerFactoryBuilder entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(descriptor, null);
    return entityManagerFactoryBuilder.build();
}
项目:high-performance-java-persistence    文件:AbstractTest.java   
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<>();
    configuration.put(AvailableSettings.INTERCEPTOR, interceptor());
    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
        new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
项目: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);
}
项目:hibernate-master-class    文件:AbstractTest.java   
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = new PersistenceUnitInfoImpl(
        getClass().getSimpleName(), entityClassNames(), getProperties()
    );

    Map<String, Object> configuration = new HashMap<>();
    configuration.put(org.hibernate.jpa.AvailableSettings.INTERCEPTOR, interceptor());
    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
        new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}