Examples of PersistenceException


Examples of br.com.yaw.sjc.exception.PersistenceException

  }
 
  @Override
  public void save(Mercadoria mercadoria) throws PersistenceException {
    if (mercadoria == null) {
      throw new PersistenceException("Informe a Mercadoria para salvar!");
    }
    Connection conn = null;
    PreparedStatement stmt = null;
    try {
      conn = ConnectionManager.getConnection();
      if (mercadoria.getId() == null) {
        stmt = getStatementInsert(conn, mercadoria);
      } else {
        stmt = getStatementUpdate(conn, mercadoria);
      }
      stmt.executeUpdate();
      conn.commit();
      log.debug("Mercadoria foi salva");
    } catch (SQLException e) {
      try { conn.rollback(); } catch (Exception sx) {}
      String errorMsg = "Erro ao salvar Mercadoria!";
      log.error(errorMsg, e);
      throw new PersistenceException(errorMsg, e);
    } finally {
      ConnectionManager.closeAll(conn, stmt);
    }
  }
View Full Code Here

Examples of br.net.woodstock.rockframework.domain.persistence.PersistenceException

          q = entityManager.createNativeQuery(filter.getFilter(), (Class) targetEntity);
        } else if (targetEntity instanceof String) {
          try {
            q = entityManager.createNativeQuery(filter.getFilter(), Class.forName((String) targetEntity));
          } catch (ClassNotFoundException e) {
            throw new PersistenceException(e);
          }
        } else {
          throw new PersistenceException("Invalid option[" + ORMOptions.OPTION_TARGET_ENTITY + "] " + targetEntity);
        }
      } else {
        q = entityManager.createNativeQuery(filter.getFilter());
      }
    } else {
View Full Code Here

Examples of br.net.woodstock.rockframework.domain.persistence.orm.PersistenceException

  private JDBCWithJNDIPersistenceHelper() {
    super();
    try {
      InputStream inputStream = ClassLoaderUtils.getResourceAsStream(JDBCWithJNDIPersistenceHelper.PROPERTIES_FILE);
      if (inputStream == null) {
        throw new PersistenceException("File " + JDBCWithJNDIPersistenceHelper.PROPERTIES_FILE + " not found in classpath");
      }

      Properties properties = PropertiesReader.getPlainTextInstance().getProperties(inputStream);
      String dataSource = properties.getProperty(JDBCWithJNDIPersistenceHelper.PROPERTY_DATASOURCE);
      Context context = new InitialContext();
      this.dataSource = (DataSource) context.lookup(dataSource);
    } catch (Exception e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

Examples of br.net.woodstock.rockframework.persistence.orm.PersistenceException

  private JDBCWithJNDIPersistenceHelper() {
    super();
    try {
      InputStream inputStream = ClassLoaderUtils.getResourceAsStream(JDBCWithJNDIPersistenceHelper.PROPERTIES_FILE);
      if (inputStream == null) {
        throw new PersistenceException("File " + JDBCWithJNDIPersistenceHelper.PROPERTIES_FILE + " not found in classpath");
      }

      Properties properties = PropertiesReader.getPlainTextInstance().getProperties(inputStream);
      String dataSource = properties.getProperty(JDBCWithJNDIPersistenceHelper.PROPERTY_DATASOURCE);
      Context context = new InitialContext();
      this.dataSource = (DataSource) context.lookup(dataSource);
    } catch (Exception e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

Examples of cn.edu.zju.acm.onlinejudge.persistence.PersistenceException

                forum.setId(rs.getLong(1));
            } finally {
                Database.dispose(ps);
            }
        } catch (SQLException e) {
            throw new PersistenceException("Failed to create forum.", e);
        } finally {
            Database.dispose(conn);
        }

    }
View Full Code Here

Examples of com.cin.exceptions.PersistenceException

    String aQuery = "select s from Stateabbv s where upper(trim(s.name)) =  '" + pStateName.toUpperCase() + "' " ;
    Query aQueryObject = manager.createQuery(aQuery);
    entity = (Stateabbv)aQueryObject.getSingleResult();
  }
  catch(Exception pException) {
    throw new PersistenceException("State does not exist");
  }
    return entity.getAbbv();
}
View Full Code Here

Examples of com.comcast.cmb.common.util.PersistenceException

  @Override
  public long getNumberOfTopicsByUser(String userId) throws PersistenceException {
   
    if (userId == null || userId.trim().length() == 0) {
      logger.error("event=list_queues error_code=invalid_user user_id=" + userId);
      throw new PersistenceException(CQSErrorCodes.InvalidParameterValue, "Invalid userId " + userId);
    }
     
    String lastArn = null;
    int sliceSize;
    long numTopics = 0;
View Full Code Here

Examples of com.im.imjutil.exception.PersistenceException

        factory = Persistence.createEntityManagerFactory(
            PERSISTENCE_UNIT);
      }
     
      if (factory == null) {
        throw new PersistenceException(Convert.toString(
            "A EntityManagerFactory para a unidade de persistencia",
            " '", PERSISTENCE_UNIT, "' e nula."));
      }
     
    } catch (Exception e) {
      throw new PersistenceException(Convert.toString(
          "Erro ao obter unidade de persistencia JPA: ",
          PERSISTENCE_UNIT), e);
    }
  }
View Full Code Here

Examples of com.salas.bb.persistence.PersistenceException

                Throwable cause = e.getCause();
                if (cause instanceof SQLException &&
                    "08001".equals(((SQLException)cause).getSQLState()))
                {
                    // Database is already in use by another process
                    throw new PersistenceException(Strings.error("db.database.is.locked"), e);
                } else
                {
                    LOG.log(Level.SEVERE, Strings.error("db.was.unable.to.perform.migration"), e);

                    // Backup current database
View Full Code Here

Examples of com.samskivert.io.PersistenceException

    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            update.persistTo(new ObjectOutputStream(out));
        } catch (IOException ioe) {
            throw new PersistenceException("Error serializing update " + update, ioe);
        }
        return out.toByteArray();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.