Search in sources :

Example 6 with Transaction

use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.

the class Application method createNewBeltPurchase.

private static Transaction createNewBeltPurchase() {
    Transaction beltPurchase = new Transaction();
    beltPurchase.setTitle("Dress Belt");
    beltPurchase.setAmount(new BigDecimal("50.00"));
    beltPurchase.setClosingBalance(new BigDecimal("0.00"));
    beltPurchase.setCreatedBy("Kevin Bowersox");
    beltPurchase.setCreatedDate(new Date());
    beltPurchase.setInitialBalance(new BigDecimal("0.00"));
    beltPurchase.setLastUpdatedBy("Kevin Bowersox");
    beltPurchase.setLastUpdatedDate(new Date());
    beltPurchase.setNotes("New Dress Belt");
    beltPurchase.setTransactionType("Debit");
    return beltPurchase;
}
Also used : Transaction(com.infiniteskills.data.entities.Transaction) BigDecimal(java.math.BigDecimal) Date(java.util.Date)

Example 7 with Transaction

use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.

the class HqlApplication method main.

public static void main(String[] args) {
    SessionFactory factory = null;
    Session session = null;
    org.hibernate.Transaction tx = null;
    try {
        factory = HibernateUtil.getSessionFactory();
        session = factory.openSession();
        tx = session.beginTransaction();
        Query query = session.createQuery("select t from Transaction t");
        List<Transaction> transactions = query.list();
        for (Transaction t : transactions) {
            System.out.println(t.getTitle());
        }
        tx.commit();
    } catch (Exception e) {
        tx.rollback();
    } finally {
        session.close();
        factory.close();
    }
}
Also used : SessionFactory(org.hibernate.SessionFactory) Query(org.hibernate.Query) Transaction(com.infiniteskills.data.entities.Transaction) Session(org.hibernate.Session)

Example 8 with Transaction

use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.

the class JpqlApplication method main.

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    EntityManagerFactory factory = null;
    EntityManager em = null;
    EntityTransaction tx = null;
    try {
        factory = Persistence.createEntityManagerFactory("infinite-finances");
        em = factory.createEntityManager();
        tx = em.getTransaction();
        tx.begin();
        TypedQuery<Transaction> query = em.createQuery("from Transaction t order by t.title", Transaction.class);
        List<Transaction> transactions = query.getResultList();
        for (Transaction t : transactions) {
            System.out.println(t.getTitle());
        }
        tx.commit();
    } catch (Exception e) {
        tx.rollback();
    } finally {
        em.close();
        factory.close();
    }
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) Transaction(com.infiniteskills.data.entities.Transaction) EntityTransaction(javax.persistence.EntityTransaction) EntityManagerFactory(javax.persistence.EntityManagerFactory)

Aggregations

Transaction (com.infiniteskills.data.entities.Transaction)8 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 EntityManager (javax.persistence.EntityManager)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 EntityTransaction (javax.persistence.EntityTransaction)2 Session (org.hibernate.Session)2 SessionFactory (org.hibernate.SessionFactory)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Query (org.hibernate.Query)1