Example #1
0
 /** {@inheritDoc} */
 @Override
 public Relay getById(Long id) throws SQLException {
   String sqlQuery = "select * from relaynames where ID=?";
   List<Relay> relays = jdbcTemplate.query(sqlQuery, new Object[] {id}, RowMappers.relay());
   if (relays.isEmpty()) {
     return null;
   }
   return relays.get(0);
 }
Example #2
0
 /** {@inheritDoc} */
 @Override
 public Collection<Relay> getAllWithTranslation() throws SQLException {
   String sqlQuery =
       "select * from relaynames "
           + "join relaybylanguage on relaynames.id=relaybylanguage.relayid "
           + "order by relaybylanguage.langid , relaybylanguage.relayid";
   logger.debug("Get all relay names with translation to all languages ");
   return jdbcTemplate.query(sqlQuery, RowMappers.relay());
 }
Example #3
0
 /** {@inheritDoc} */
 @Override
 public Collection<Relay> getAll(Long langId) throws SQLException {
   String sqlQuery =
       "select r1.id, r1.name, r2.relayid, r2.langid, r2.unicodetext from relaynames r1 "
           + "left join relaybylanguage r2 on r1.id=r2.relayid and langid="
           + langId;
   logger.debug("Get all relay names with given language id [{}] ", langId);
   return jdbcTemplate.query(sqlQuery, RowMappers.relay());
 }
 @Override
 public Transaction getById(Long id) throws SQLException {
   logger.debug("Get transactions with id [{}]", id);
   String sql = "select * from transactions where ID=?";
   List<Transaction> transactionList =
       jdbcTemplate.query(sql, new Object[] {id}, RowMappers.transaction());
   if (transactionList.isEmpty()) {
     return null;
   }
   return transactionList.get(0);
 }
  @Override
  public List<Transaction> getAllByFlockId(Long flockId) throws SQLException {
    logger.debug("Get all transactions data with flock id {} ", flockId);
    String sql = "select * from transactions where FlockID=?";

    DatabaseMetaData dbmd = jdbcTemplate.getDataSource().getConnection().getMetaData();
    ResultSet rs = dbmd.getTables(null, "APP", "TRANSACTION", null);
    if (!rs.next()) {
      System.out.println("not exist");
    }

    return jdbcTemplate.query(sql, new Object[] {flockId}, RowMappers.transaction());
  }
Example #6
0
 /** {@inheritDoc} */
 @Override
 public Collection<Relay> getAll() throws SQLException {
   logger.debug("Get all relay names ");
   return jdbcTemplate.query("select * from relaynames order by id,name", RowMappers.relay());
 }