Search in sources :

Example 16 with Item

use of org.jpwh.model.advanced.Item in project microservices by pwillhan.

the class Enum method storeLoadEnum.

@Test
public void storeLoadEnum() throws Exception {
    UserTransaction tx = TM.getUserTransaction();
    try {
        tx.begin();
        EntityManager em = JPA.createEntityManager();
        Item someItem = new Item();
        someItem.setName("Some item");
        someItem.setDescription("This is some description.");
        someItem.setAuctionType(AuctionType.LOWEST_BID);
        em.persist(someItem);
        tx.commit();
        em.close();
        Long ITEM_ID = someItem.getId();
        tx.begin();
        em = JPA.createEntityManager();
        Item item = em.find(Item.class, ITEM_ID);
        assertEquals(item.getAuctionType(), AuctionType.LOWEST_BID);
        tx.commit();
        em.close();
    } finally {
        TM.rollback();
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) Item(org.jpwh.model.advanced.Item) EntityManager(javax.persistence.EntityManager) JPATest(org.jpwh.env.JPATest) Test(org.testng.annotations.Test)

Aggregations

EntityManager (javax.persistence.EntityManager)16 UserTransaction (javax.transaction.UserTransaction)16 Item (org.jpwh.model.advanced.Item)16 JPATest (org.jpwh.env.JPATest)12 Test (org.testng.annotations.Test)12 BigDecimal (java.math.BigDecimal)6 Bid (org.jpwh.model.advanced.Bid)4 Date (java.util.Date)2 Random (java.util.Random)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Blob (java.sql.Blob)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 List (java.util.List)1 Query (javax.persistence.Query)1