예제 #1
0
 public static void delete(User1 User1) {
   EntityManager em = DBUtil.getEmFactory().createEntityManager();
   EntityTransaction trans = em.getTransaction();
   trans.begin();
   try {
     em.remove(em.merge(User1));
     trans.commit();
   } catch (Exception e) {
     System.out.println(e);
     trans.rollback();
   } finally {
     em.close();
   }
 }
예제 #2
0
 public static User1 selectUser1(String email) {
   EntityManager em = DBUtil.getEmFactory().createEntityManager();
   String qString = "SELECT u FROM User1 u " + "WHERE u.email = :email";
   TypedQuery<User1> q = em.createQuery(qString, User1.class);
   q.setParameter("email", email);
   try {
     User1 User1 = q.getSingleResult();
     return User1;
   } catch (NoResultException e) {
     return null;
   } finally {
     em.close();
   }
 }
예제 #3
0
 public static void insert(Lineitem lineitem) {
   EntityManager em = DBUtil.getEmFactory().createEntityManager();
   EntityTransaction trans = em.getTransaction();
   trans.begin();
   try {
     em.persist(lineitem);
     trans.commit();
   } catch (Exception e) {
     System.out.println(e);
     trans.rollback();
   } finally {
     em.close();
   }
 }