Search in sources :

Example 1 with User

use of org.jpwh.model.complexschemas.naturalprimarykey.User in project microservices by pwillhan.

the class NaturalPrimaryKey method storeLoad.

@Test
public void storeLoad() throws Exception {
    UserTransaction tx = TM.getUserTransaction();
    try {
        tx.begin();
        EntityManager em = JPA.createEntityManager();
        {
            User user = new User("johndoe");
            em.persist(user);
        }
        tx.commit();
        em.close();
        tx.begin();
        em = JPA.createEntityManager();
        {
            User user = em.find(User.class, "johndoe");
            assertNotNull(user);
        }
        tx.commit();
        em.close();
    } finally {
        TM.rollback();
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) EntityManager(javax.persistence.EntityManager) User(org.jpwh.model.complexschemas.naturalprimarykey.User) JPATest(org.jpwh.env.JPATest) Test(org.testng.annotations.Test)

Aggregations

EntityManager (javax.persistence.EntityManager)1 UserTransaction (javax.transaction.UserTransaction)1 JPATest (org.jpwh.env.JPATest)1 User (org.jpwh.model.complexschemas.naturalprimarykey.User)1 Test (org.testng.annotations.Test)1