Spring 使用ORM系列-持久化JPA
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
给了它一个EntityManager的代理 EntityManager并不是线程安全的,一般来讲并不适合注入到像Repository这样共享的单例bean中 |
||||
|
|
|
|
|
|||
|
|
@PersistenceUnit和@PersistenceContext并不是Spring的注解,它们是由JPA规范提供的 需要<context:annotation-config>或<context:component-scan>会自动注册PersistenceAnnotationBean-PostProcessor bean
否则的话,我们需要显式地注 册这个bean:
|
|
||||
|
|
|
|
|
|
||
|
|
使用Spring的数据异常体系 |
|
|
|
||
|
|
|
|
|
|
|