Sleep mode: replacement for the Ejb3Configuration class

Sorry for the long story, but I wanted to give a good idea of ​​why we are doing what we are doing.

Currently, our application uses Hibernate 3.6, and we want to upgrade to Hibernate 4.3.

The application was specially written to avoid using persistence.xmlJPA to configure and create, EntityManagerFactoryand instead uses the Hibernate class Ejb3Configuration, like this one (example):

Properties properties = new Properties();
properties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
properties.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
properties.put("hibernate.show_sql", "false");
properties.put("hibernate.format_sql", "true");

Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(properties);

DataSource dataSource = dataSourceProvider.get();
cfg.setDataSource(dataSource);

//add the annotated classes
cfg.addAnnotatedClass(SomePersistentObject.class);

EntityManagerFactory factory = cfg.buildEntityManagerFactory();

, , , - ( ), Tomcat, "" . , " ", jar /WEB-INF/lib. " " "" -. , "" , -. , HTTP-.

, , , EntityManagerFactory. , , .

, , JPA Java, - , "" . Java , XML . XML, ​​ persistence.xml . copy/paste.

, JPA Java, XML.

: Hibernate 4.3 - ? , ?

, - - , , XML?

jar - /META-INF/persistence.xml, , ?

!!!

-Ryan

+4
1

, persistence.xml -, JPA .

- JPA , persistence.xml . persistence-unit persistence.xml.

, persistence.xml, JPA . JPA , , persistence.xml .

, , , . , API- Hibernate, , - - DataNucleus JPA, .

+2

Source: https://habr.com/ru/post/1529436/


All Articles