@Test
 public void testCollision2ndTime() {
   Dining dining = Dining.createDining("100.00", "1234123412341234", "1234567890");
   rewardNetwork.rewardAccountFor(dining);
   String sql = "select SAVINGS from T_ACCOUNT_BENEFICIARY where NAME = ?";
   assertEquals(Double.valueOf(4.00), jdbcTemplate.queryForObject(sql, Double.class, "Annabelle"));
   assertEquals(Double.valueOf(4.00), jdbcTemplate.queryForObject(sql, Double.class, "Corgan"));
 }
 /** {@inheritDoc} */
 public String getUserPassword(String username) {
   SimpleJdbcTemplate jdbcTemplate =
       new SimpleJdbcTemplate(SessionFactoryUtils.getDataSource(getSessionFactory()));
   Table table = AnnotationUtils.findAnnotation(User.class, Table.class);
   return jdbcTemplate.queryForObject(
       "select password from " + table.name() + " where username=?", String.class, username);
 }
예제 #3
0
  @Override
  public Message getMessage(Long id) {
    Map<String, Object> paramMap = new HashMap<>();
    paramMap.put("msgId", id);
    Message message = jdbcTemplate.queryForObject(SELECT_MESSAGE_SQL, messageRowMapper, paramMap);

    return message;
  }
예제 #4
0
 @Override
 public Health find(Integer pk) {
   Health health = null;
   try {
     health = template.queryForObject(SELECT_QUERY_PK, healthRowMapper, pk);
   } catch (DataAccessException e) {
     throw new LunchException(e);
   }
   return health;
 }
예제 #5
0
 public CspTo findByPkgName(String name) {
   SimpleJdbcTemplate sjt = getSimpleJdbcTemplate();
   String sql = "select * from PIDB_Csp where PKG_NAME='" + name + "'";
   CspTo pkgTo;
   try {
     pkgTo = sjt.queryForObject(sql, new GenericRowMapper<CspTo>(CspTo.class), new Object[] {});
   } catch (Exception e) {
     // e.printStackTrace();
     return null;
   }
   return pkgTo;
 }
예제 #6
0
  public Employee getSalaryForEmployee(Employee employee) {
    int salary =
        simpleJdbcTemplate.queryForObject(
            QUERY_SALARY_FOR_ID, Integer.class, new Object[] {employee.getEmpId()});

    logger.info(
        "getSalaryForEmployee for employee id " + employee.getEmpId() + " returned " + salary);

    employee.setSalary(salary);

    return employee;
  }
예제 #7
0
  /**
   * 获取相应的Object
   *
   * @param sql
   * @param className
   * @param obj
   * @return
   */
  public Object getObject(String sql, Class<? extends Serializable> className, Object[] obj) {

    Object object = null;
    try {
      object =
          simpleJdbcTemplate.queryForObject(sql, BeanPropertyRowMapper.newInstance(className), obj);
    } catch (DataAccessException e) {
      log.info(e);
      return null;
      // throw new DaoException("数据库操作失败!",e);
    }
    return object;
  }
예제 #8
0
 @Override
 public User getUser(Long id) {
   User user = jdbcTemplate.queryForObject(SELECT_USER_SQL, userRowMapper, id);
   return user;
 }