Java 类org.springframework.orm.jpa.JpaTemplate 实例源码

项目:class-guard    文件:JpaDaoSupportTests.java   
@Test
public void testJpaDaoSupportWithJpaTemplate() throws Exception {
    JpaTemplate template = new JpaTemplate();
    final List test = new ArrayList();
    JpaDaoSupport dao = new JpaDaoSupport() {
        @Override
        protected void initDao() {
            test.add("test");
        }
    };
    dao.setJpaTemplate(template);
    dao.afterPropertiesSet();
    assertNotNull("jpa template not created", dao.getJpaTemplate());
    assertEquals("incorrect JpaTemplate", template, dao.getJpaTemplate());
    assertEquals("initDao not called", test.size(), 1);
}
项目:class-guard    文件:OpenEntityManagerInViewTests.java   
@Before
public void setUp() throws Exception {
    factory = mock(EntityManagerFactory.class);
    manager = mock(EntityManager.class);

    template = new JpaTemplate(factory);
    template.afterPropertiesSet();

    given(factory.createEntityManager()).willReturn(manager);
}
项目:omr    文件:DAOGenericoHibernate.java   
public void setJpaTemplate(JpaTemplate jpaTemplate) {
    this.jpaTemplate = jpaTemplate;
}
项目:omr    文件:DAOGenericoHibernate.java   
public void setJpaTemplate(JpaTemplate jpaTemplate) {
    this.jpaTemplate = jpaTemplate;
}
项目:omr    文件:DAOGenericoHibernate.java   
public void setJpaTemplate(JpaTemplate jpaTemplate) {
    this.jpaTemplate = jpaTemplate;
}
项目:omr    文件:DAOGenericoHibernate.java   
/**
 * Configura session factory.
 * 
 * @param sessionFactory
 *            o novo(a) session factory
 */
public void setSessionFactory(EntityManager entityManager) {
    this.setEntityManager(entityManager);
    this.setJpaTemplate(new JpaTemplate(entityManager));        
}
项目:omr    文件:DAOGenericoHibernate.java   
/**
 * Configura session factory.
 * 
 * @param sessionFactory
 *            o novo(a) session factory
 */
public void setSessionFactory(EntityManager entityManager) {
    this.setEntityManager(entityManager);
    this.setJpaTemplate(new JpaTemplate(entityManager));        
}
项目:omr    文件:DAOGenericoHibernate.java   
/**
 * Configura session factory.
 * 
 * @param sessionFactory
 *            o novo(a) session factory
 */
public void setSessionFactory(EntityManager entityManager) {
    this.setEntityManager(entityManager);
    this.setJpaTemplate(new JpaTemplate(entityManager));        
}
项目:class-guard    文件:JpaDaoSupport.java   
/**
 * Create a JpaTemplate for the given EntityManagerFactory.
 * Only invoked if populating the DAO with a EntityManagerFactory reference!
 * <p>Can be overridden in subclasses to provide a JpaTemplate instance
 * with different configuration, or a custom JpaTemplate subclass.
 * @param entityManagerFactory the JPA EntityManagerFactory to create a JpaTemplate for
 * @return the new JpaTemplate instance
 * @see #setEntityManagerFactory
 */
protected JpaTemplate createJpaTemplate(EntityManagerFactory entityManagerFactory) {
    return new JpaTemplate(entityManagerFactory);
}
项目:class-guard    文件:JpaDaoSupport.java   
/**
 * Create a JpaTemplate for the given EntityManager.
 * Only invoked if populating the DAO with a EntityManager reference!
 * <p>Can be overridden in subclasses to provide a JpaTemplate instance
 * with different configuration, or a custom JpaTemplate subclass.
 * @param entityManager the JPA EntityManager to create a JpaTemplate for
 * @return the new JpaTemplate instance
 * @see #setEntityManagerFactory
 */
protected JpaTemplate createJpaTemplate(EntityManager entityManager) {
    return new JpaTemplate(entityManager);
}
项目:class-guard    文件:JpaDaoSupport.java   
/**
 * Set the JpaTemplate for this DAO explicitly,
 * as an alternative to specifying a EntityManagerFactory.
 * @see #setEntityManagerFactory
 */
public final void setJpaTemplate(JpaTemplate jpaTemplate) {
    this.jpaTemplate = jpaTemplate;
}
项目:class-guard    文件:JpaDaoSupport.java   
/**
 * Return the JpaTemplate for this DAO, pre-initialized
 * with the EntityManagerFactory or set explicitly.
 */
public final JpaTemplate getJpaTemplate() {
  return jpaTemplate;
}