Example usage for org.hibernate.jpa AvailableSettings CDI_BEAN_MANAGER

List of usage examples for org.hibernate.jpa AvailableSettings CDI_BEAN_MANAGER

Introduction

In this page you can find the example usage for org.hibernate.jpa AvailableSettings CDI_BEAN_MANAGER.

Prototype

String CDI_BEAN_MANAGER

To view the source code for org.hibernate.jpa AvailableSettings CDI_BEAN_MANAGER.

Click Source Link

Usage

From source file:net.satago.tapestry5.jpa.test.HibernateJpaTestModule.java

License:Apache License

@Contribute(EntityManagerSource.class)
public static void configurePersistenceUnit(MappedConfiguration<String, PersistenceUnitConfigurer> cfg,
        final ObjectLocator objectLocator) {
    PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() {
        @Override/*from   w  w  w  . java2 s.  co m*/
        public void configure(TapestryPersistenceUnitInfo unitInfo) {
            unitInfo.transactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL)
                    .persistenceProviderClassName("org.hibernate.jpa.HibernatePersistenceProvider")
                    .excludeUnlistedClasses(false).addProperty("javax.persistence.jdbc.user", "sa")
                    .addProperty("javax.persistence.jdbc.password", "sa")
                    .addProperty("javax.persistence.jdbc.driver", "org.h2.Driver")
                    .addProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:jpatest_hibernate")
                    .addProperty("hibernate.hbm2ddl.auto", "update").addProperty("hibernate.show_sql", "true");

            unitInfo.getProperties().put(AvailableSettings.CDI_BEAN_MANAGER,
                    objectLocator.autobuild(TapestryCDIBeanManagerForJPAEntityListeners.class));
        }
    };
    cfg.add("jpatest", configurer);
}