Search in sources :

Example 1 with PersistenceUnitInfoDescriptor

use of org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor in project robo4j by Robo4J.

the class PersistenceContextBuilder method build.

public PersistenceContextBuilder build() {
    PersistenceDescriptorFactory persistenceDescriptorFactory = new PersistenceDescriptorFactory();
    PersistenceUnitInfo persistenceUnitInfo = persistenceDescriptorFactory.get(RoboClassLoader.getInstance().getClassLoader(), sourceType, packages);
    PersistenceUnitDescriptor persistenceUnitDescriptor = new PersistenceUnitInfoDescriptor(persistenceUnitInfo);
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilderImpl(persistenceUnitDescriptor, new HashMap<>());
    registeredClasses = persistenceDescriptorFactory.registeredClasses();
    dataSourceContext = new DataSourceProxy(builder.build());
    return this;
}
Also used : PersistenceUnitInfoDescriptor(org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor) EntityManagerFactoryBuilderImpl(org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl) PersistenceUnitInfo(javax.persistence.spi.PersistenceUnitInfo) EntityManagerFactoryBuilder(org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder) PersistenceDescriptorFactory(com.robo4j.db.sql.jpa.PersistenceDescriptorFactory) PersistenceUnitDescriptor(org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor)

Example 2 with PersistenceUnitInfoDescriptor

use of org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor in project hibernate-orm by hibernate.

the class BootstrapTest method test_bootstrap_bootstrap_native_EntityManagerFactory_example.

@Test
public void test_bootstrap_bootstrap_native_EntityManagerFactory_example() {
    try {
        //tag::bootstrap-native-EntityManagerFactory-example[]
        String persistenceUnitName = "CRM";
        List<String> entityClassNames = new ArrayList<>();
        Properties properties = new Properties();
        PersistenceUnitInfoImpl persistenceUnitInfo = new PersistenceUnitInfoImpl(persistenceUnitName, entityClassNames, properties);
        Map<String, Object> integrationSettings = new HashMap<>();
        integrationSettings.put(AvailableSettings.INTERCEPTOR, new CustomSessionFactoryInterceptor());
        EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(new PersistenceUnitInfoDescriptor(persistenceUnitInfo), integrationSettings);
        EntityManagerFactory emf = entityManagerFactoryBuilder.build();
    //end::bootstrap-native-EntityManagerFactory-example[]
    } catch (Exception ignore) {
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) PersistenceUnitInfoDescriptor(org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor) EntityManagerFactoryBuilderImpl(org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl) EntityManagerFactory(javax.persistence.EntityManagerFactory) Test(org.junit.Test)

Aggregations

EntityManagerFactoryBuilderImpl (org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl)2 PersistenceUnitInfoDescriptor (org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor)2 PersistenceDescriptorFactory (com.robo4j.db.sql.jpa.PersistenceDescriptorFactory)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)1 EntityManagerFactoryBuilder (org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder)1 PersistenceUnitDescriptor (org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor)1 Test (org.junit.Test)1