Package javax.persistence

Examples of javax.persistence.EntityTransaction


    try {
      States st = Statemanagement.getInstance().getStateById(states_id);

      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();

      Adresses adr = new Adresses();
      adr.setAdditionalname(additionalname);
      adr.setComment(comment);
      adr.setStarttime(new Date());
      adr.setFax(fax);
      adr.setStreet(street);
      adr.setTown(town);
      adr.setZip(zip);
      adr.setStates(st);
      adr.setPhone(phone);
      adr.setEmail(email);

      adr = session.merge(adr);
      Long id = adr.getAdresses_id();

      tx.commit();
      PersistenceSessionUtil.closeSession(idf);

      log.debug("added id " + id);

      return id;
View Full Code Here


  public Long saveAddressObj(Adresses adr) {
    try {
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();

      adr = session.merge(adr);
      Long id = adr.getAdresses_id();

      tx.commit();
      PersistenceSessionUtil.closeSession(idf);

      log.debug("added id " + id);

      return id;
View Full Code Here

  public Adresses getAdressbyId(long adresses_id) {
    try {
      String hql = "select c from Adresses as c where c.adresses_id = :adresses_id";
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("adresses_id", new Long(adresses_id));
      Adresses addr = null;
      try {
        addr = (Adresses) query.getSingleResult();
        } catch (NoResultException ex) {
        }
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      return addr;
    } catch (Exception ex2) {
      log.error("getAdressbyId",ex2);
    }
View Full Code Here

    String hql = "select c from Adresses as c " +
        "where c.email LIKE :email";
        //"and c.deleted <> :deleted";
    Object idf = PersistenceSessionUtil.createSession();
    EntityManager session = PersistenceSessionUtil.getSession();
    EntityTransaction tx = session.getTransaction();
      tx.begin();
    Query query = session.createQuery(hql);
    query.setParameter("email", email);
    //query.setParameter("deleted", "true");
   
    List<Adresses> addr = query.getResultList();
   
    tx.commit();
    PersistenceSessionUtil.closeSession(idf);
 
    log.debug("retrieveAddressByEmail "+addr.size());
   
    if (addr.size() > 0) {
View Full Code Here

     
      Adresses adr = this.getAdressbyId(adresses_id);

      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();

      adr.setAdditionalname(additionalname);
      adr.setComment(comment);
      adr.setUpdatetime(new Date());
      adr.setFax(fax);
      adr.setStreet(street);
      adr.setTown(town);
      adr.setZip(zip);
      adr.setStates(st);
      adr.setPhone(phone);
      adr.setEmail(email);

      if (adr.getAdresses_id() == null) {
        session.persist(adr);
          } else {
            if (!session.contains(adr)) {
              session.merge(adr);
          }
      }

      tx.commit();
      PersistenceSessionUtil.closeSession(idf);

      return adr;
    } catch (Exception ex2) {
      log.error("updateAdress",ex2);
View Full Code Here

   
    try {
       
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();

      if (addr.getAdresses_id() == null) {
        session.persist(addr);
          } else {
            if (!session.contains(addr)) {
              session.merge(addr);
          }
      }
     
      tx.commit();
       
      PersistenceSessionUtil.closeSession(idf);

      return addr;
    } catch (Exception ex2) {
View Full Code Here

     
      String hql = "select c from UserSipData as c where c.userSipDataId = :userSipDataId";
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("userSipDataId", userSipDataId);
      UserSipData userSipData = null;
      try {
        userSipData = (UserSipData) query.getSingleResult();
        } catch (NoResultException ex) {
        }
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return userSipData;
    } catch (Exception ex2) {
      log.error("getUserSipDataById",ex2);
View Full Code Here

     
      userSipData.setInserted(new Date());
     
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      userSipData = session.merge(userSipData);
      Long userSipDataId = userSipData.getUserSipDataId();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return userSipDataId;
    } catch (Exception ex2) {
      log.error("[addUserSipData] ",ex2);
View Full Code Here

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

   */
  public Long addState(String statename) {
    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();

      States st = new States();
      st.setName(statename);
      st.setStarttime(new Date());
      st.setDeleted("false");

      st = session.merge(st);
      Long id = st.getState_id();

      tx.commit();
      PersistenceSessionUtil.closeSession(idf);

      log.debug("added id " + id);

      return id;
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.