use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.
the class HibernateApplication method main.
@SuppressWarnings("unchecked")
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();
List<Transaction> transactions = session.createCriteria(Transaction.class).addOrder(Order.desc("title")).list();
for (Transaction t : transactions) {
System.out.println(t.getTitle());
}
tx.commit();
} catch (Exception e) {
e.printStackTrace();
tx.rollback();
} finally {
session.close();
factory.close();
}
}
use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.
the class JpaApplication method main.
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();
// select t from transaction t
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Transaction> criteriaQuery = cb.createQuery(Transaction.class);
Root<Transaction> root = criteriaQuery.from(Transaction.class);
criteriaQuery.select(root);
TypedQuery<Transaction> query = em.createQuery(criteriaQuery);
List<Transaction> transactions = query.getResultList();
for (Transaction t : transactions) {
System.out.println(t.getTitle());
}
tx.commit();
} catch (Exception e) {
tx.rollback();
e.printStackTrace();
} finally {
em.close();
factory.close();
}
}
use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.
the class Application method createNewBeltPurchase.
private static Transaction createNewBeltPurchase(Account account) {
Transaction beltPurchase = new Transaction();
beltPurchase.setAccount(account);
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;
}
use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.
the class Application method createShoePurchase.
private static Transaction createShoePurchase(Account account) {
Transaction shoePurchase = new Transaction();
shoePurchase.setAccount(account);
shoePurchase.setTitle("Work Shoes");
shoePurchase.setAmount(new BigDecimal("100.00"));
shoePurchase.setClosingBalance(new BigDecimal("0.00"));
shoePurchase.setCreatedBy("Kevin Bowersox");
shoePurchase.setCreatedDate(new Date());
shoePurchase.setInitialBalance(new BigDecimal("0.00"));
shoePurchase.setLastUpdatedBy("Kevin Bowersox");
shoePurchase.setLastUpdatedDate(new Date());
shoePurchase.setNotes("Nice Pair of Shoes");
shoePurchase.setTransactionType("Debit");
return shoePurchase;
}
use of com.infiniteskills.data.entities.Transaction in project microservices by pwillhan.
the class Application method createShoePurchase.
private static Transaction createShoePurchase() {
Transaction shoePurchase = new Transaction();
shoePurchase.setTitle("Work Shoes");
shoePurchase.setAmount(new BigDecimal("100.00"));
shoePurchase.setClosingBalance(new BigDecimal("0.00"));
shoePurchase.setCreatedBy("Kevin Bowersox");
shoePurchase.setCreatedDate(new Date());
shoePurchase.setInitialBalance(new BigDecimal("0.00"));
shoePurchase.setLastUpdatedBy("Kevin Bowersox");
shoePurchase.setLastUpdatedDate(new Date());
shoePurchase.setNotes("Nice Pair of Shoes");
shoePurchase.setTransactionType("Debit");
return shoePurchase;
}
Aggregations