Java 类org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor 实例源码

项目:spring4-understanding    文件:PersistenceContextTransactionTests.java   
@Before
public void setUp() throws Exception {
    factory = mock(EntityManagerFactory.class);
    manager = mock(EntityManager.class);
    tx = mock(EntityTransaction.class);

    JpaTransactionManager tm = new JpaTransactionManager(factory);
    tt = new TransactionTemplate(tm);

    given(factory.createEntityManager()).willReturn(manager);
    given(manager.getTransaction()).willReturn(tx);
    given(manager.isOpen()).willReturn(true);

    bean = new EntityManagerHoldingBean();
    @SuppressWarnings("serial")
    PersistenceAnnotationBeanPostProcessor pabpp = new PersistenceAnnotationBeanPostProcessor() {
        @Override
        protected EntityManagerFactory findEntityManagerFactory(String unitName, String requestingBeanName) {
            return factory;
        }
    };
    pabpp.postProcessPropertyValues(null, null, bean, "bean");

    assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty());
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
}
项目:social-media-analytic-system    文件:DataSourceConfig.java   
/**
 * Bean that helps Spring to understand JPA annotations
 * @return Bean
 */
@Bean
public PersistenceAnnotationBeanPostProcessor paPostProcessor(){
    return new PersistenceAnnotationBeanPostProcessor();
}
项目:jsf-exmple    文件:PersistenceConfig.java   
@Bean
public static PersistenceAnnotationBeanPostProcessor persistenceAnnotationBeanPostProcessor() {
    return new PersistenceAnnotationBeanPostProcessor();
}
项目:gtfs-java    文件:JpaRepositoryConfig.java   
@Bean
public PersistenceAnnotationBeanPostProcessor persistenceAnnotation() {
    return new PersistenceAnnotationBeanPostProcessor();
}
项目:b4    文件:B4CoreRootConfig.java   
@Bean
public static PersistenceAnnotationBeanPostProcessor persistenceAnnotationBeanPostProcessor() {
    return new PersistenceAnnotationBeanPostProcessor();
}
项目:interview-preparation    文件:DBConfig.java   
/**
 * It’s important to understand that @PersistenceUnit and @PersistenceContext aren’t Spring annotations;<br>
 * they’re provided by the JPA specification. In order for Spring to understand them and inject an EntityManagerFactory or EntityManager,<br>
 * Spring’s PersistenceAnnotationBeanPostProcessor must be configured. <br>
 * If you’re already using <context:annotation-config> or <context:component-scan>,<br>
 * then you’re good to go because those configuration elements automatically register a PersistenceAnnotationBeanPostProcessor bean.
 *
 * @return PersistenceAnnotationBeanPostProcessor
 */

@Bean
public PersistenceAnnotationBeanPostProcessor paPostProcessor() {
    return new PersistenceAnnotationBeanPostProcessor();
}
项目:interview-preparation    文件:DatabaseConfig.java   
/**
 * It’s important to understand that @PersistenceUnit and @PersistenceContext aren’t Spring annotations;<br>
 * they’re provided by the JPA specification. In order for Spring to understand them and inject an EntityManagerFactory or EntityManager,<br>
 * Spring’s PersistenceAnnotationBeanPostProcessor must be configured. <br>
 * If you’re already using <context:annotation-config> or <context:component-scan>,<br>
 * then you’re good to go because those configuration elements automatically register a PersistenceAnnotationBeanPostProcessor bean.
 *
 * @return PersistenceAnnotationBeanPostProcessor
 */

@Bean
public PersistenceAnnotationBeanPostProcessor paPostProcessor() {
    return new PersistenceAnnotationBeanPostProcessor();
}