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:net.noday.d4c.dao.DnsrecordDao.java

public void update(DnsRecord obj) {
    String sql = "update dnsrecord set record_type=:recordType,value=:value,ttl=:ttl where id=:id";
    namedjdbc.update(sql, new BeanPropertySqlParameterSource(obj));
}

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

public long insertRoleAndRoleRights(Role role) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertRoleQuery, new BeanPropertySqlParameterSource(role), keyHolder,
            new String[] { "id" });

    long roleId = keyHolder.getKey().longValue();
    role.setId(roleId);/*from w ww . j  a v a2 s  .  c o  m*/

    for (Right right : role.getRights()) {
        RoleRight roleRight = new RoleRight(roleId, right.name());
        template.update(insertRoleRightQuery, new BeanPropertySqlParameterSource(roleRight));
    }

    return roleId;
}

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

public long insertRequisitionMember(RequisitionGroupMember rgMember) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    template.update(insertRequisitionGroupMemberQuery, new BeanPropertySqlParameterSource(rgMember), keyHolder,
            new String[] { "id" });

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

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

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

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

    boolean result = countDispatcher > 0;

    if (LOG.isInfoEnabled()) {
        if (result) {
            LOG.info("User is exist. User : " + user);
        } else {//from  ww  w. j av  a  2 s . c  o m
            LOG.info("User isn't exist. User : " + user);
        }
    }

    return result;
}

From source file:airport.database.dispatcher.airplane.FlightDaoImpl.java

@Override
public void addFlight(Flight flight) {
    SqlParameterSource paramertFlight = new BeanPropertySqlParameterSource(flight);

    jdbcTemplate.update(SQL_QUERY_ADD_FLIGHT, paramertFlight);

    if (LOG.isInfoEnabled()) {
        LOG.info("add flight. Flight" + (flight != null ? flight.toString() : ""));
    }/*from   w w  w . jav a 2  s. c  o  m*/
}

From source file:org.smigo.user.JdbcUserDao.java

@Override
public int addUser(User user) {
    return insert.executeAndReturnKey(new BeanPropertySqlParameterSource(user)).intValue();
}

From source file:net.noday.d4c.dao.SubdomainDao.java

public void saveWithId(Subdomain obj) {
    String sql = "insert into domain(id,name,fullname,password,salt,pid) values(:id,:name,:fullname,:password,:salt,:pid)";
    namedJdbc.update(sql, new BeanPropertySqlParameterSource(obj));
}

From source file:com.webstersmalley.countdown.db.JdbcCountdownDao.java

@Override
@Transactional(readOnly = false)//from  ww  w . j  a  v  a  2  s. co  m
public void addWord(WordBean word) {
    String sql = "insert into words (theWord, length, countA, countB, countC, countD, countE, countF, countG, countH, countI, countJ, countK, countL, countM, countN, countO, countP, countQ, countR, countS, countT, countU, countV, countW, countX, countY, countZ) values (:theWord, :length, :countA, :countB, :countC, :countD, :countE, :countF, :countG, :countH, :countI, :countJ, :countK, :countL, :countM, :countN, :countO, :countP, :countQ, :countR, :countS, :countT, :countU, :countV, :countW, :countX, :countY, :countZ)";

    SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(word);

    namedParameterJdbcTemplate.update(sql, namedParameters);
}

From source file:org.springmodules.samples.cache.guava.repository.jdbc.JdbcPostRepository.java

@Override
public void update(Post post) {
    getNamedParameterJdbcTemplate().update("update posts set content = :content where id = :id",
            new BeanPropertySqlParameterSource(post));
}

From source file:airport.database.services.setting.SettingFrontEndDaoImpl.java

@Override
public SettingFrontEnd getSettingFrontEnd(User user) {
    SqlParameterSource parameterUser = new BeanPropertySqlParameterSource(user);

    SettingFrontEnd settingFrontEndResult = jdbcOperations.queryForObject(SQL_QUERY_SELECT_SETTING,
            parameterUser, new SettingFrontEndRowMapper());

    if (LOG.isInfoEnabled()) {
        LOG.info("get setting front end of user. User : " + user + ". Result " + settingFrontEndResult);
    }/*from  w w  w . j a  va  2 s.  c  om*/

    return settingFrontEndResult;
}