當前位置: 首頁>>代碼示例>>Java>>正文


Java JpaTransactionManager類代碼示例

本文整理匯總了Java中org.springframework.orm.jpa.JpaTransactionManager的典型用法代碼示例。如果您正苦於以下問題:Java JpaTransactionManager類的具體用法?Java JpaTransactionManager怎麽用?Java JpaTransactionManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JpaTransactionManager類屬於org.springframework.orm.jpa包,在下文中一共展示了JpaTransactionManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testJpaComponentEMFandTM

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Test
public void testJpaComponentEMFandTM() throws Exception {
    JpaComponent comp = new JpaComponent();
    comp.setCamelContext(context);
    assertNull(comp.getEntityManagerFactory());
    assertNull(comp.getTransactionManager());

    EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
    JpaTransactionManager tm = new JpaTransactionManager(fac);
    tm.afterPropertiesSet();

    comp.setEntityManagerFactory(fac);
    comp.setTransactionManager(tm);

    assertSame(fac, comp.getEntityManagerFactory());
    assertSame(tm, comp.getTransactionManager());

    JpaEndpoint jpa = (JpaEndpoint) comp.createEndpoint("jpa://" + SendEmail.class.getName());
    assertNotNull(jpa);
    assertNotNull(jpa.getEntityType());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:JpaComponentTest.java

示例2: responseHighlighterInterceptor

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
/**
	 * This interceptor adds some pretty syntax highlighting in responses when a browser is detected
	 */
/*	@Bean(autowire = Autowire.BY_TYPE)
	public IServerInterceptor responseHighlighterInterceptor() {
		ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
		return retVal;
	}*/

	/*	@Bean(autowire = Autowire.BY_TYPE)
	public IServerInterceptor subscriptionSecurityInterceptor() {
		SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3();
		return retVal;
	}*/

	@Bean
	public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
		JpaTransactionManager retVal = new JpaTransactionManager();
		retVal.setEntityManagerFactory(entityManagerFactory);
		return retVal;
	}
 
開發者ID:Discovery-Research-Network-SCCM,項目名稱:FHIR-CQL-ODM-service,代碼行數:22,代碼來源:FhirServerTestConfigDstu3.java

示例3: transactionManager

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Bean
@Autowired
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
	JpaTransactionManager txManager = new JpaTransactionManager();
	txManager.setEntityManagerFactory(emf);
	return txManager;
}
 
開發者ID:dockersamples,項目名稱:atsea-sample-shop-app,代碼行數:8,代碼來源:JpaConfiguration.java

示例4: setUp

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:27,代碼來源:PersistenceContextTransactionTests.java

示例5: testJpaCoexistsHappily

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Test
public void testJpaCoexistsHappily() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.initialize:false");
	this.context.register(EntityConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
			SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
	// This can fail if security @Conditionals force early instantiation of the
	// HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
	this.context.refresh();
	assertThat(this.context.getBean(JpaTransactionManager.class)).isNotNull();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:SecurityAutoConfigurationTests.java

示例6: testJpaEndpointCtrUrlEMFandTM

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
/**
 * 
 * @deprecated
 */
@Deprecated
@Test
public void testJpaEndpointCtrUrlEMFandTM() throws Exception {
    EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
    JpaTransactionManager tm = new JpaTransactionManager(fac);
    tm.afterPropertiesSet();

    JpaEndpoint jpa = new JpaEndpoint("jpa://org.apache.camel.examples.SendEmail", fac, tm);
    jpa.setEntityType(SendEmail.class);

    assertSame(fac, jpa.getEntityManagerFactory());
    assertSame(tm, jpa.getTransactionManager());

    assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
    assertEquals("camel", jpa.getPersistenceUnit());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:JpaEndpointTest.java

示例7: testJpaEndpointCustomEMFandTM

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Test
public void testJpaEndpointCustomEMFandTM() throws Exception {
    EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
    JpaTransactionManager tm = new JpaTransactionManager(fac);
    tm.afterPropertiesSet();

    JpaEndpoint jpa = new JpaEndpoint();
    jpa.setEntityType(SendEmail.class);

    jpa.setEntityManagerFactory(fac);
    jpa.setTransactionManager(tm);

    assertSame(fac, jpa.getEntityManagerFactory());
    assertSame(tm, jpa.getTransactionManager());

    assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
    assertEquals("camel", jpa.getPersistenceUnit());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:JpaEndpointTest.java

示例8: retrieveSiteById

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
protected Site retrieveSiteById(final Long id, final boolean persistentResult) {
  //Since the methods on this class are frequently called during regular page requests and transactions are expensive,
    //only run the operation under a transaction if there is not already an entity manager in the view
    final Site[] response = new Site[1];
    transUtil.runOptionalTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
        @Override
        public void execute() throws Throwable {
            Site site = siteDao.retrieve(id);
            if (persistentResult) {
                response[0] = site;
            } else {
                response[0] = getNonPersistentSite(site);
            }
        }
    }, RuntimeException.class, !TransactionSynchronizationManager.hasResource(((JpaTransactionManager) transUtil.getTransactionManager()).getEntityManagerFactory()));

    return response[0];
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:19,代碼來源:SiteServiceImpl.java

示例9: retrieveDefaultSite

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
protected Site retrieveDefaultSite(final boolean persistentResult) {
    //Since the methods on this class are frequently called during regular page requests and transactions are expensive,
    //only run the operation under a transaction if there is not already an entity manager in the view
    final Site[] response = new Site[1];
    transUtil.runOptionalTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
        @Override
        public void execute() throws Throwable {
            Site defaultSite = siteDao.retrieveDefaultSite();
            if (persistentResult) {
                response[0] = defaultSite;
            } else {
                response[0] = getNonPersistentSite(defaultSite);
            }
        }
    }, RuntimeException.class, !TransactionSynchronizationManager.hasResource(((JpaTransactionManager) transUtil.getTransactionManager()).getEntityManagerFactory()));

    return response[0];
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:19,代碼來源:SiteServiceImpl.java

示例10: findAllSites

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
protected List<Site> findAllSites(final boolean persistentResult) {
  //Since the methods on this class are frequently called during regular page requests and transactions are expensive,
    //only run the operation under a transaction if there is not already an entity manager in the view
    final List<Site> response = new ArrayList<Site>();
    transUtil.runOptionalTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
        @Override
        public void execute() throws Throwable {
            List<Site> sites = siteDao.readAllActiveSites();
            for (Site site : sites) {
                if (persistentResult) {
                    response.add(site);
                } else {
                    response.add(getNonPersistentSite(site));
                }
            }
        }
    }, RuntimeException.class, !TransactionSynchronizationManager.hasResource(((JpaTransactionManager) transUtil.getTransactionManager()).getEntityManagerFactory()));

    return response;
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:21,代碼來源:SiteServiceImpl.java

示例11: testJpaCoexistsHappily

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Test
public void testJpaCoexistsHappily() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.initialize:false");
	this.context.register(EntityConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
			SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
	// This can fail if security @Conditionals force early instantiation of the
	// HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
	this.context.refresh();
	assertNotNull(this.context.getBean(JpaTransactionManager.class));
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:18,代碼來源:SecurityAutoConfigurationTests.java

示例12: retrieveSiteById

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
protected Site retrieveSiteById(final Long id, final boolean persistentResult) {
  //Since the methods on this class are frequently called during regular page requests and transactions are expensive,
    //only run the operation under a transaction if there is not already an entity manager in the view
    if (id == null) { return null; }
    final Site[] response = new Site[1];
    transUtil.runOptionalTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
        @Override
        public void execute() throws Throwable {
            Site site = siteDao.retrieve(id);
            if (persistentResult) {
                response[0] = site;
            } else {
                response[0] = getNonPersistentSite(site);
            }
        }
    }, RuntimeException.class, !TransactionSynchronizationManager.hasResource(((JpaTransactionManager) transUtil.getTransactionManager()).getEntityManagerFactory()));

    return response[0];
}
 
開發者ID:takbani,項目名稱:blcdemo,代碼行數:20,代碼來源:SiteServiceImpl.java

示例13: transactionManagerEvents

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Autowired
@Bean
public PlatformTransactionManager transactionManagerEvents(@Qualifier("eventsEntityManagerFactory") final EntityManagerFactory emf) {
    final JpaTransactionManager mgmr = new JpaTransactionManager();
    mgmr.setEntityManagerFactory(emf);
    return mgmr;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:8,代碼來源:JpaEventsConfiguration.java

示例14: transactionManagerGoogleAuthenticator

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Autowired
@Bean
public PlatformTransactionManager transactionManagerGoogleAuthenticator(
        @Qualifier("googleAuthenticatorEntityManagerFactory") final EntityManagerFactory emf) {
    final JpaTransactionManager mgmr = new JpaTransactionManager();
    mgmr.setEntityManagerFactory(emf);
    return mgmr;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:9,代碼來源:GoogleAuthenticatorJpaConfiguration.java

示例15: transactionManagerMfaAuthnTrust

import org.springframework.orm.jpa.JpaTransactionManager; //導入依賴的package包/類
@Autowired
@Bean
public PlatformTransactionManager transactionManagerMfaAuthnTrust(
        @Qualifier("mfaTrustedAuthnEntityManagerFactory") final EntityManagerFactory emf) {
    final JpaTransactionManager mgmr = new JpaTransactionManager();
    mgmr.setEntityManagerFactory(emf);
    return mgmr;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:9,代碼來源:JdbcMultifactorAuthnTrustConfiguration.java


注:本文中的org.springframework.orm.jpa.JpaTransactionManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。