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:com.griddynamics.spring.batch.football.internal.JdbcPlayerDao.java

public void savePlayer(Player player) {

    getSimpleJdbcTemplate().update(INSERT_PLAYER, new BeanPropertySqlParameterSource(player));

}

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

public long insertProgramSupported(ProgramSupported programSupported) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertProgramsSupported, new BeanPropertySqlParameterSource(programSupported), keyHolder,
            new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    programSupported.setId(id);//w  ww .ja v a2s.  c  o m
    return id;
}

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

public long insertSchedule(ProcessingSchedule processingSchedule) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertScheduleQuery, new BeanPropertySqlParameterSource(processingSchedule), keyHolder,
            new String[] { "id" });

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

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

@Override
public int add(Customer customer) {
    String sql = "INSERT INTO customer (fname, lname, company, street, city, state, country, postcode, telephone, email, comments, date_added)"
            + " VALUES (:fname, :lname, :company, :street, :city, :state, :country, :postcode, :telephone, :email, :comments, NOW())";

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

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

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

public long insertRequisition(Rnr rnr) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    BeanPropertySqlParameterSource paramSource = new BeanPropertySqlParameterSource(rnr);
    paramSource.registerSqlType("status", VARCHAR);
    template.update(insertRequisitionQuery, paramSource, keyHolder, new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    rnr.setId(id);//from w ww .  j  av a  2 s  .co m

    logger.debug("{} requisition {} ", new Date(), id);
    return id;
}

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

@Override
public Dispatcher getDispatcher(User user) {
    SqlParameterSource parameterUser = new BeanPropertySqlParameterSource(user);
    Dispatcher dispatcherResult;/*from w w w  . j a  va  2  s . c o m*/

    try {
        dispatcherResult = jdbcTemplate.queryForObject(SQL_QUERY_GET_DISPATCHER, parameterUser,
                new DispatcherMapper());
    } catch (EmptyResultDataAccessException e) {
        LOG.info("such dispatcher isn't present. User : " + user);

        return new Dispatcher();
    }

    LOG.info("such dispatcher is present. User : " + user + ". Dispatcher : " + dispatcherResult);

    return dispatcherResult;
}

From source file:ar.com.springbasic.dao.AdminDaoImpl.java

@Override
public boolean save(Admin admin) {
    //        MapSqlParameterSource paramMap = new MapSqlParameterSource();
    //        paramMap.addValue("nombre", admin.getNombre());
    //        paramMap.addValue("cargo", admin.getCargo());
    //        paramMap.addValue("fechaCreacion", admin.getFechaCreacion());

    BeanPropertySqlParameterSource paramMap = new BeanPropertySqlParameterSource(admin);

    return jdbcTemplate.update(
            "insert into springbd.admin (nombre, cargo, fechaCreacion) values (:nombre, :cargo, :fechaCreacion) ",
            paramMap) == 1;/*  w w w . jav a  2s  . com*/
}

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

@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void add(Product product) {

    // generate the private and public keys and then store them in the database.
    LicenceGenerator lg = new LicenceGenerator(null);
    product.setLicence_params(lg.getEncodedPrivateKey());
    product.setTemp(lg.getEncodedToXMLPublicKey());

    String sql = "INSERT INTO product (id, name, licence_params, temp)"
            + " VALUES (:id, :name, :licence_params, :temp)";

    SqlParameterSource sqlParameters = new BeanPropertySqlParameterSource(product);
    jdbcTemplate.update(sql, sqlParameters);
}

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

public long insertPeriod(ProcessingPeriod period) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertPeriodQuery, new BeanPropertySqlParameterSource(period), keyHolder,
            new String[] { "id" });

    long id = keyHolder.getKey().longValue();
    period.setId(id);/*from w w  w.  java2s  .co  m*/
    return id;
}

From source file:org.smigo.species.varieties.JdbcVarietyDao.java

@Override
public int addVariety(Variety variety) {
    return insert.executeAndReturnKey(new BeanPropertySqlParameterSource(variety)).intValue();
}