Search in sources :

Example 1 with Bid

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

the class MappedSubselect method storeItemAndBids.

public Long storeItemAndBids() throws Exception {
    UserTransaction tx = TM.getUserTransaction();
    tx.begin();
    EntityManager em = JPA.createEntityManager();
    Item item = new Item();
    item.setName("Some item");
    item.setDescription("This is some description.");
    em.persist(item);
    for (int i = 1; i <= 3; i++) {
        Bid bid = new Bid();
        bid.setAmount(new BigDecimal(10 + i));
        bid.setItem(item);
        em.persist(bid);
    }
    tx.commit();
    em.close();
    return item.getId();
}
Also used : UserTransaction(javax.transaction.UserTransaction) Item(org.jpwh.model.advanced.Item) EntityManager(javax.persistence.EntityManager) Bid(org.jpwh.model.advanced.Bid) BigDecimal(java.math.BigDecimal)

Example 2 with Bid

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

the class TransformingColumns method storeItemAndBids.

public Long storeItemAndBids() throws Exception {
    UserTransaction tx = TM.getUserTransaction();
    tx.begin();
    EntityManager em = JPA.createEntityManager();
    Item item = new Item();
    item.setName("Some item");
    item.setMetricWeight(2);
    item.setDescription("This is some description.");
    em.persist(item);
    for (int i = 1; i <= 3; i++) {
        Bid bid = new Bid();
        bid.setAmount(new BigDecimal(10 + i));
        bid.setItem(item);
        em.persist(bid);
    }
    tx.commit();
    em.close();
    return item.getId();
}
Also used : UserTransaction(javax.transaction.UserTransaction) Item(org.jpwh.model.advanced.Item) EntityManager(javax.persistence.EntityManager) Bid(org.jpwh.model.advanced.Bid) BigDecimal(java.math.BigDecimal)

Example 3 with Bid

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

the class DerivedProperties method storeItemAndBids.

public Long storeItemAndBids() throws Exception {
    UserTransaction tx = TM.getUserTransaction();
    tx.begin();
    EntityManager em = JPA.createEntityManager();
    Item item = new Item();
    item.setName("Some item");
    item.setDescription("This is some description.");
    em.persist(item);
    for (int i = 1; i <= 3; i++) {
        Bid bid = new Bid();
        bid.setAmount(new BigDecimal(10 + i));
        bid.setItem(item);
        em.persist(bid);
    }
    tx.commit();
    em.close();
    return item.getId();
}
Also used : UserTransaction(javax.transaction.UserTransaction) Item(org.jpwh.model.advanced.Item) EntityManager(javax.persistence.EntityManager) Bid(org.jpwh.model.advanced.Bid) BigDecimal(java.math.BigDecimal)

Example 4 with Bid

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

the class GeneratedProperties method storeItemAndBids.

public Long storeItemAndBids() throws Exception {
    UserTransaction tx = TM.getUserTransaction();
    tx.begin();
    EntityManager em = JPA.createEntityManager();
    Item item = new Item();
    item.setName("Some item");
    item.setDescription("This is some description.");
    em.persist(item);
    for (int i = 1; i <= 3; i++) {
        Bid bid = new Bid();
        bid.setAmount(new BigDecimal(10 + i));
        bid.setItem(item);
        em.persist(bid);
    }
    tx.commit();
    em.close();
    return item.getId();
}
Also used : UserTransaction(javax.transaction.UserTransaction) Item(org.jpwh.model.advanced.Item) EntityManager(javax.persistence.EntityManager) Bid(org.jpwh.model.advanced.Bid) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)4 EntityManager (javax.persistence.EntityManager)4 UserTransaction (javax.transaction.UserTransaction)4 Bid (org.jpwh.model.advanced.Bid)4 Item (org.jpwh.model.advanced.Item)4