Example usage for org.springframework.jdbc.core.namedparam BeanPropertySqlParameterSource BeanPropertySqlParameterSource

List of usage examples for org.springframework.jdbc.core.namedparam BeanPropertySqlParameterSource BeanPropertySqlParameterSource

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.namedparam BeanPropertySqlParameterSource BeanPropertySqlParameterSource.

Prototype

public BeanPropertySqlParameterSource(Object object) 

Source Link

Document

Create a new BeanPropertySqlParameterSource for the given bean.

Usage

From source file:org.openlmis.performancetesting.dao.ProgramDAO.java

public long insertProgram(Program program) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertProgramQuery, new BeanPropertySqlParameterSource(program), keyHolder,
            new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    program.setId(id);//from  w  w  w.  jav  a  2 s  .  co  m
    return id;
}

From source file:airport.database.services.users.UsersStorageDaoImpl.java

@Override
public boolean isThere(User user) {
    SqlParameterSource parameterUser = new BeanPropertySqlParameterSource(user);

    int countDispatcher = jdbcTemplate.queryForObject(SQL_QUERY_EXIST_USER, parameterUser, Integer.class);

    boolean result = countDispatcher > 0;

    if (LOG.isInfoEnabled()) {
        if (result) {
            LOG.info("User is exist. User : " + user);
        } else {//from w  w w .jav  a2s  .  c  o  m
            LOG.info("User isn't exist. User : " + user);
        }
    }

    return result;
}

From source file:org.openlmis.performancetesting.dao.ProgramRnrTemplateDAO.java

public void insertRnrTemplate(ProgramRnrTemplate rnrTemplate) {
    for (RnrColumn rnrColumn : rnrTemplate.getRnrColumns()) {
        template.update(insertRnrTemplateQuery, new BeanPropertySqlParameterSource(rnrColumn));
    }/*w ww.ja v  a2  s .co m*/
}

From source file:org.openlmis.performancetesting.dao.SupplyLineDAO.java

public long insertSupplyLine(SupplyLine supplyLine) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertSupplyLineQuery, new BeanPropertySqlParameterSource(supplyLine), keyHolder,
            new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    supplyLine.setId(id);/*from  w ww .j  a  va 2  s  .  c  o  m*/
    return id;
}

From source file:org.openlmis.performancetesting.dao.ProgramProductDAO.java

public long insertProgramProduct(ProgramProduct programProduct) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertProgramQuery, new BeanPropertySqlParameterSource(programProduct), keyHolder,
            new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    programProduct.setId(id);/*w ww  .  j a v  a2  s. com*/
    return id;
}

From source file:com.tt.utils.DBUtils.java

public List<ActivityInfo> getActivityInfo(SearchCriteria searchCriteria) {

    List<ActivityInfo> result = null;
    try {/* w  ww  . j a v  a2  s  .  co  m*/
        result = simplejdbcTemplate.query(
                DBQueryMap.getQueryString(DBQueryMap.GET_ACTIVITY_INFO_BY_LOCATION_EXTERNALID),
                ParameterizedBeanPropertyRowMapper.newInstance(ActivityInfo.class),
                new BeanPropertySqlParameterSource(searchCriteria));

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }

    return result;

}

From source file:com.xinferin.dao.DAOActivationImpl.java

@Override
public int add(Activation activation) {
    String sql = "INSERT INTO activation (licence_id, date, machine_code, ipaddress, success)"
            + " VALUES (:licence_id, NOW(), :machine_code, :ipaddress, :success)";

    SqlParameterSource sqlParameters = new BeanPropertySqlParameterSource(activation);
    KeyHolder keyHolder = new GeneratedKeyHolder();
    jdbcTemplate.update(sql, sqlParameters, keyHolder);

    return keyHolder.getKey().intValue();
}

From source file:org.openlmis.performancetesting.dao.FacilityApprovedProductDAO.java

public long insertFacilityApprovedProduct(FacilityApprovedProduct facilityApprovedProduct) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertFacilityApprovedProductQuery,
            new BeanPropertySqlParameterSource(facilityApprovedProduct), keyHolder, new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    facilityApprovedProduct.setId(id);/*from   ww  w  .j ava2  s .  co  m*/
    return id;
}

From source file:org.openlmis.performancetesting.dao.SupervisoryNodeDAO.java

public long insertSupervisoryNode(SupervisoryNode supervisoryNode) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertSupervisoryNodeSql, new BeanPropertySqlParameterSource(supervisoryNode), keyHolder,
            new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    supervisoryNode.setId(id);/*w ww .j a  v  a2  s . c  om*/
    return id;
}

From source file:com.xinferin.dao.DAOLicenceImpl.java

@Override
public int add(Licence licence) {
    String sql = "INSERT INTO licence (product_id, issue_date)" + " VALUES (:product_id, NOW())";

    SqlParameterSource sqlParameters = new BeanPropertySqlParameterSource(licence);
    KeyHolder keyHolder = new GeneratedKeyHolder();
    jdbcTemplate.update(sql, sqlParameters, keyHolder);

    return keyHolder.getKey().intValue();
}