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:ar.com.springbasic.dao.AdminDaoImpl.java

@Override
public boolean update(Admin admin) {
    return jdbcTemplate.update(
            "update springbd.admin set nombre=:nombre, cargo=:cargo, fechaCreacion=:fechaCreacion where idAd=:idAd",
            new BeanPropertySqlParameterSource(admin)) == 1;
}

From source file:com.mesut.daopattern.OffersDAO.java

public boolean addOffer(Offer offer) {
    BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(offer);
    return jdbc.update("insert into offers (name, email, text) values(:name, :email, :text)", params) == 1;
}

From source file:org.cloudfoundry.samples.handson.ex6.CopyController.java

/**
 * Actually performs the copy and redirects to the list.
 *//*from  w w  w .ja  v  a  2  s  .c o  m*/
@RequestMapping(value = "/ex6", method = RequestMethod.POST)
public String copy() {
    for (Person person : fetchPersons(fromTemplate)) {
        toTemplate.update("insert into Persons(firstName, lastName, age) values (:firstName, :lastName, :age)",
                new BeanPropertySqlParameterSource(person));
    }
    return "redirect:/ex6";
}

From source file:com.stehno.sjdbcx.reflection.DefaultParamMapper.java

private void addBean(final MapSqlParameterSource source, final Object beanObj) {
    final BeanPropertySqlParameterSource beanSource = new BeanPropertySqlParameterSource(beanObj);

    for (final String name : beanSource.getReadablePropertyNames()) {
        source.addValue(name, beanSource.getValue(name));
    }//from  w w  w .  j a v a  2  s .c o  m
}

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

public long insertVendor(Vendor vendor) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertVendorQuery, new BeanPropertySqlParameterSource(vendor), keyHolder,
            new String[] { "id" });

    long vendorId = keyHolder.getKey().longValue();
    vendor.setId(vendorId);/*from   w w w. j av a  2  s. c o  m*/
    return vendorId;

}

From source file:org.ala.spatial.services.dao.ActionDAOImpl.java

@Override
public void addAction(Action action) {
    logger.info("Adding a new " + action.getType() + " action by " + action.getEmail() + " via "
            + action.getAppid());/*from   www.j  a va 2s  .c  om*/
    logger.info("\nlayers: " + action.getService().getLayers() + "\nextra: " + action.getService().getExtra());
    action.setTime(new Timestamp(new Date().getTime()));

    SqlParameterSource sprm = new BeanPropertySqlParameterSource(action.getService());
    Number serviceId = insertService.executeAndReturnKey(sprm);
    action.getService().setId(serviceId.longValue());
    action.setServiceid(serviceId.longValue());

    SqlParameterSource parameters = new BeanPropertySqlParameterSource(action);
    Number actionId = insertAction.executeAndReturnKey(parameters);
    action.setId(actionId.longValue());

}

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

public long insertFacilityType(FacilityType facilityType) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertFacilityTypeQuery, new BeanPropertySqlParameterSource(facilityType), keyHolder,
            new String[] { "id" });

    long autoGeneratedKey = keyHolder.getKey().longValue();
    facilityType.setId(autoGeneratedKey);
    return autoGeneratedKey;
}

From source file:com.mesut.daopattern.OffersDAO.java

public boolean updateOffer(Offer offer) {
    BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(offer);
    return jdbc.update("update offers set name=:name, email=:email, text=:text where id=:id", params) == 1;
}

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

public void insertLossesAndAdjustmentType(LossesAndAdjustmentsType adjustmentsType) {
    template.update(insertAdjustmentTypeQuery, new BeanPropertySqlParameterSource(adjustmentsType));
}

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

public long insertProductForm(ProductForm productForm) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertFormQuery, new BeanPropertySqlParameterSource(productForm), keyHolder,
            new String[] { "id" });
    long autoGeneratedKey = keyHolder.getKey().longValue();
    productForm.setId(autoGeneratedKey);
    return autoGeneratedKey;
}