您有没有人知道在Hibernate 4 +中以编程方式从Hibernate创建JPA EntityManagerFactory impl的首选方法是什么?
我使用hsql执行此操作,但是已将其删除;
Properties props = new Properties();
props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect");
props.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
props.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:aname");
props.setProperty("hibernate.connection.username", "sa" );
props.setProperty("hibernate.connection.password", "" );
Ejb3Configuration config3 = new Ejb3Configuration();
config3.setProperties(props);
config3.addFile("src/org/adligo/i/storage/entities/keyValue.xml");
impl = config3.buildEntityManagerFactory();
这似乎是新的方式,但我一直在接受NPE;
impl = new EntityManagerFactoryImpl(transactionType, false,
clazz, config, serviceRegistry, "i_storage_tests_persistence_unit");
TIA, 斯科特