当前位置: 首页>>代码示例>>Java>>正文


Java EntityManager.joinTransaction方法代码示例

本文整理汇总了Java中javax.persistence.EntityManager.joinTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java EntityManager.joinTransaction方法的具体用法?Java EntityManager.joinTransaction怎么用?Java EntityManager.joinTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.persistence.EntityManager的用法示例。


在下文中一共展示了EntityManager.joinTransaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: carLifecycleXA

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create, find and delete car using XA Transactions
 * @param ut
 * @param em
 * @throws Exception
 */
protected void carLifecycleXA(UserTransaction ut, EntityManager em) throws Exception {
    ut.begin();
    em.joinTransaction();
    delete(em, Car.class, BLUE_PLATE);
    em.persist(createBlueCar());
    ut.commit();

    Car c = em.find(Car.class, BLUE_PLATE);
    assertBlueCar(c);

    ut.begin();
    em.joinTransaction();
    delete(em, Car.class, BLUE_PLATE);
    ut.commit();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:22,代码来源:AbstractCarJPAITest.java

示例2: truckLifecycleXA

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create, find and delete car using XA Transactions
 * @param ut
 * @param em
 * @throws Exception
 */
protected void truckLifecycleXA(UserTransaction ut, EntityManager em) throws Exception {
	ut.begin();
	em.joinTransaction();
	delete(em, Truck.class, BLUE_PLATE);
	em.persist(createBlueTruck());
	ut.commit();
	
	Truck t = em.find(Truck.class, BLUE_PLATE);
	assertBlueTruck(t);
	
	ut.begin();
	em.joinTransaction();
	delete(em, Truck.class, BLUE_PLATE);
	ut.commit();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:22,代码来源:AbstractCarJPAITest.java

示例3: cleanup

import javax.persistence.EntityManager; //导入方法依赖的package包/类
private void cleanup(EntityManager em) throws Exception {
    ut.begin();
    em.joinTransaction();
    delete(em, Car.class, BLACK_CAR_PLATE);
    delete(em, Car.class, BLUE_PLATE);
    ut.commit();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:8,代码来源:JPAContainerTest.java

示例4: testEmSupplier

import javax.persistence.EntityManager; //导入方法依赖的package包/类
@Test
public void testEmSupplier() throws Exception {
    EmSupplier emSupplier = getService(EmSupplier.class, "(osgi.unit.name=" + XA_TEST_UNIT + ")");
    Coordination coordination = coordinator.begin("test", 0);
    try {
        EntityManager em = emSupplier.get();
        carLifecycleXA(ut, em);

        Query countQuery = em.createQuery("SELECT Count(c) from Car c");
        assertEquals(0l, countQuery.getSingleResult());

        ut.begin();
        em.joinTransaction();
        em.persist(createBlueCar());
        em.persist(createGreenCar());
        ut.commit();

        assertEquals(2l, countQuery.getSingleResult());

        TypedQuery<Car> carQuery = em.createQuery("Select c from Car c ORDER by c.engineSize", Car.class);
        List<Car> list = carQuery.getResultList();
        assertEquals(2, list.size());

        assertBlueCar(list.get(0));
        assertGreenCar(list.get(1));

        ut.begin();
        em.joinTransaction();
        changeToRed(em.find(Car.class, BLUE_PLATE));
        em.remove(em.find(Car.class, GREEN_CAR_PLATE));
        em.persist(createBlackCar());
        ut.commit();

        assertEquals(2l, countQuery.getSingleResult());
        list = carQuery.getResultList();
        assertEquals(2, list.size());

        assertBlackCar(list.get(0));
        assertChangedBlueCar(list.get(1));

        cleanup(em);
    } finally {
        coordination.end();
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:46,代码来源:JPAContainerTest.java


注:本文中的javax.persistence.EntityManager.joinTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。