Package javax.persistence

Examples of javax.persistence.EntityTransaction


     
      String hql = "delete from UserContacts where owner.user_id = :ownerId";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
     
      Query query = session.createQuery(hql);
          query.setParameter("ownerId",ownerId);
          int rowCount = query.executeUpdate();
     
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return rowCount;     
    } catch (Exception e) {
      log.error("[deleteAllUserContacts]",e);
View Full Code Here


      String hql = "select count(c.userContactId) from UserContacts c " +
              "where c.contact.user_id = :user_id AND c.owner.user_id = :ownerId ";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("user_id", user_id);
      query.setParameter("ownerId", ownerId);
      List ll = query.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      log.info("checkUserContacts"+(Long)ll.get(0));
     
      return (Long)ll.get(0);
View Full Code Here

      String hql = "select c from UserContacts c " +
              "where c.hash like :hash ";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("hash", hash);
      List<UserContacts> ll = query.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      if (ll.size() > 0) {
        return ll.get(0);
      }
View Full Code Here

              "AND c.pending = :pending " +
              "AND c.contact.deleted <> 'true'";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("ownerId", ownerId);
      query.setParameter("pending", pending);
      List<UserContacts> ll = query.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return ll;
     
    } catch (Exception e) {
View Full Code Here

              "AND c.shareCalendar = :shareCalendar " +
              "AND c.contact.deleted <> 'true'";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("contactId", contactId);
      query.setParameter("shareCalendar", shareCalendar);
      List<UserContacts> ll = query.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return ll;
     
    } catch (Exception e) {
View Full Code Here

              "AND c.pending = :pending " +
              "AND c.contact.deleted <> 'true'";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("user_id", user_id);
      query.setParameter("pending", pending);
      List<UserContacts> ll = query.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return ll;
     
    } catch (Exception e) {
View Full Code Here

      String hql = "select c from UserContacts c " +
              "where c.userContactId = :userContactId";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("userContactId", userContactId);
      UserContacts userContacts = null;
      try {
        userContacts = (UserContacts) query.getSingleResult();
        } catch (NoResultException ex) {
        }
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return userContacts;
     
    } catch (Exception e) {
View Full Code Here

      userContacts.setPending(pending);
      userContacts.setUpdated(new Date());
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      if (userContacts.getUserContactId() == 0) {
        session.persist(userContacts);
          } else {
            if (!session.contains(userContacts)) {
              session.merge(userContacts);
          }
      }
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return userContactId;
     
    } catch (Exception e) {
View Full Code Here

    try {
      userContacts.setUpdated(new Date());
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      if (userContacts.getUserContactId() == 0) {
        session.persist(userContacts);
          } else {
            if (!session.contains(userContacts)) {
              session.merge(userContacts);
          }
      }
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
    } catch (Exception e) {
      log.error("[updateContact]",e);
    }
View Full Code Here

      ac.setUpdatetime(new Date());
      ac.setDeleted("true");
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      if (ac.getTypId() == null) {
        session.persist(ac);
          } else {
            if (!session.contains(ac)) {
              session.merge(ac);
          }
      }
           
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      return typId;
    } catch (Exception ex2) {
      log.error("[deleteAppointmentReminderTyp]: " + ex2);
    }
View Full Code Here

TOP

Related Classes of javax.persistence.EntityTransaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.