Persistence:在Java中提到persistence的話,通常是指透過SQL將object instance對應並存放到database中。
Bootstrapping:表示初始化並且開始一個software component。
Bootstrapping:表示初始化並且開始一個software component。
Hibernate中,分別有JPA
Bootstrapping與Native
Bootstrapping,(建議使用JPA-standardized
bootstrapping)
JPA
Bootstrapping的方式
JPA的方式中最後目標是要建立javax.persistence.EntityManagerFactory instance。
在JPA標準中定義了兩種bootstrapping,分別是EE,與SE,
- EE bootstrapping,指的是manage and inject the persistence context on behalf of the application.
- SE bootstrapping,指的是everything else
而在Hibernate中使用container-bootstrapping
以及 application-bootstrapping兩個術語(term)來表示。
另外在JPA
2.1 specification中的7.6
與 7.7有說明使用EntityManager
instances的細節。
Container-bootstrapping中,container會為每個定義在META-INF/persistence.xml
configuration
file中的persistent-unit建立一個EntityManagerFactory然後讓application能夠透過注入(injection)javax.persistence.PersistenceUnit
annotation或是透過JNDI的方式使用。
Application-bootstrapping:application要透過
可以透過entityManager instance的unwrap()來使用provider(也就是Hibernate)的API。
META-INF/persistence.xml檔:
使用EntityManagerjavax.persistence.Persistence
來建立EntityManagerFactory。可以透過entityManager instance的unwrap()來使用provider(也就是Hibernate)的API。
source: https://github.com/readStudy/Hibernate-ORM-Study/tree/master/SetUpHibernateOrm
Reference: http://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html
沒有留言:
張貼留言