Package javax.persistence

Examples of javax.persistence.EntityTransaction


      String hql = "select a from AppointmentReminderTyps a " +
          "WHERE a.deleted <> :deleted ";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("deleted", "true");
     
       
      List<AppointmentReminderTyps> listAppointmentReminderTyp = query.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return listAppointmentReminderTyp;
    } catch (Exception ex2) {
      log.error("[getAppointmentReminderTypList]: " + ex2);
View Full Code Here


   */
  private List getRoomsOrganisationByOrganisationId(long organisation_id, int start, int max, String orderby, boolean asc){
    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      String hql = "select c from Rooms_Organisation as c " +
      "where c.organisation.organisation_id = :organisation_id " +
      "AND c.deleted <> :deleted";
      if (orderby.startsWith("c.")){
        hql += "ORDER BY "+orderby;
      } else {
        hql += "ORDER BY " + "c." + orderby;
      }
      if (asc) {
        hql += " ASC";
      } else {
        hql += " DESC";
      }
     
      Query q = session.createQuery(hql);
     
      q.setParameter("organisation_id", organisation_id);
      q.setParameter("deleted", "true");
      q.setFirstResult(start);
      q.setMaxResults(max);
      List<Rooms_Organisation> ll = q.getResultList();
     
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return ll;
    } catch (Exception ex2) {
      log.error("[getRoomsByOrganisation] ", ex2);
View Full Code Here

 
  private Rooms_Organisation getRoomsOrganisationByOrganisationIdAndRoomId(long organisation_id, long rooms_id){
    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      String hql = "select c from Rooms_Organisation as c " +
      "where c.room.rooms_id = :rooms_id " +
      "AND c.organisation.organisation_id = :organisation_id " +
      "AND c.deleted <> :deleted";
      Query q = session.createQuery(hql);
     
      q.setParameter("rooms_id", rooms_id);
      q.setParameter("organisation_id", organisation_id);
      q.setParameter("deleted", "true");
      List<Rooms_Organisation> ll = q.getResultList();
     
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      if (ll.size()>0){
        return (Rooms_Organisation)ll.get(0);
      }
    } catch (Exception ex2) {
View Full Code Here

   */
  public List getRoomsOrganisationByRoomsId(long rooms_id){
    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      String hql = "select c from Rooms_Organisation as c " +
      "where c.room.rooms_id = :rooms_id " +
      "AND c.deleted <> :deleted";
      Query q = session.createQuery(hql);
     
      q.setParameter("rooms_id", rooms_id);
      q.setParameter("deleted", "true");
      List<Rooms_Organisation> ll = q.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      return ll;
    } catch (Exception ex2) {
      log.error("[getRoomsByOrganisation] ", ex2);
    }
View Full Code Here

 
  public List<Rooms_Organisation> getRoomsOrganisations(){
    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<Rooms_Organisation> cq = cb.createQuery(Rooms_Organisation.class);
      Root<Rooms_Organisation> c = cq.from(Rooms_Organisation.class);
      TypedQuery<Rooms_Organisation> q = session.createQuery(cq);
      List<Rooms_Organisation> ll = q.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      return ll;
    } catch (Exception ex2) {
      log.error("[getRoomsByOrganisation] ", ex2);
    }
View Full Code Here

          r.setName(name);
          r.setRoomtype(this.getRoomTypesById(roomtypes_id));
          r.setUpdatetime(new Date());
          Object idf = PersistenceSessionUtil.createSession();
          EntityManager session = PersistenceSessionUtil.getSession();
          EntityTransaction tx = session.getTransaction();
          tx.begin();
          if (r.getRooms_id() == null) {
            session.persist(r);
              } else {
                if (!session.contains(r)) {
                  session.merge(r);
              }
          }
          tx.commit();
          PersistenceSessionUtil.closeSession(idf);
        }
      }
    } catch (Exception ex2) {
      log.error("[updateRoom] ", ex2);
View Full Code Here

      r.setWaitForRecording(waitForRecording);
      r.setAllowRecording(allowRecording);
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      if (r.getRooms_id() == null) {
        session.persist(r);
          } else {
            if (!session.contains(r)) {
              r = session.merge(r);
          }
      }
     
      session.flush();
     
      session.refresh(r);
     
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      if (organisations!=null){
        Long t = this.updateRoomOrganisations(organisations, r);
        if (t==null) return null;
View Full Code Here

       
        r.setIsModeratedRoom(isModeratedRoom);
       
        Object idf = PersistenceSessionUtil.createSession();
        EntityManager session = PersistenceSessionUtil.getSession();
        EntityTransaction tx = session.getTransaction();
        tx.begin();
        if (r.getRooms_id() == null) {
          session.persist(r);
            } else {
              if (!session.contains(r)) {
                session.merge(r);
            }
        }
        tx.commit();
        PersistenceSessionUtil.closeSession(idf);
       
        //FIXME: Organizations will not be changed when you do an update as Moderator
       
        if (roomModerators!=null) {
View Full Code Here

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

    try {     
      rOrg.setDeleted("true");
      rOrg.setUpdatetime(new Date());
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      if (rOrg.getRooms_organisation_id() == null) {
        session.persist(rOrg);
          } else {
            if (!session.contains(rOrg)) {
              session.merge(rOrg);
          }
      }
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      return rOrg.getRooms_organisation_id();
    } catch (Exception ex2) {
      log.error("[deleteRoomsOrganisation] ", 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.