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.ala.spatial.services.dao.ApplicationDAOImpl.java

@Override
public void addApplication(Application app) {
    logger.info("Adding a new application " + app.getName() + " by " + app.getOrganisation() + " ("
            + app.getEmail() + ") ");

    app.setRegtime(new Timestamp(new Date().getTime()));
    try {//ww w.jav a2s  .c o m
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        md.update((app.getName() + app.getEmail() + app.getRegtime()).getBytes());
        byte byteData[] = md.digest();

        //convert the byte to hex format method 1
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }
        app.setAppid(sb.toString());
    } catch (NoSuchAlgorithmException ex) {
        java.util.logging.Logger.getLogger(ApplicationDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
    }

    System.out.println(app.toString());

    SqlParameterSource parameters = new BeanPropertySqlParameterSource(app);
    Number appUid = insertApplication.executeAndReturnKey(parameters);
    app.setId(appUid.longValue());
}

From source file:com.example.dfa.demo.service.DfaDemoServiceImpl.java

@Override
public NextEventDTO processWorkflowEvent(NextEventDTO nextEvent) {
    SqlParameterSource inParams = new BeanPropertySqlParameterSource(nextEvent);
    processWorkflowEventSpaCall.execute(inParams);
    NextEventDTO result = jdbcTemplate.queryForObject(
            "SELECT dws.DFA_WORKFLOW_ID,dws.DFA_STATE_ID FROM dfa.DFA_WORKFLOW JOIN dfa.DFA_WORKFLOW_STATE dws ON dws.DFA_WORKFLOW_ID = IF(SUB_STATE, dfa.DFA_WORKFLOW.SPAWN_DFA_WORKFLOW_ID, dfa.DFA_WORKFLOW.DFA_WORKFLOW_ID) AND dws.IS_CURRENT = 1 WHERE dfa.DFA_WORKFLOW.DFA_WORKFLOW_ID = ?",
            new BeanPropertyRowMapper<NextEventDTO>(NextEventDTO.class), nextEvent.getDfaWorkflowId());
    return result;
}

From source file:com.rambird.miles.repository.jdbc.JdbcMileRepositoryImpl.java

@Override
public void save(MyMile mile) throws DataAccessException {
    BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(mile);
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    mile.setUserName(auth.getName()); //get logged in username

    if (mile.isNew()) {
        Number newKey = this.insertMile.executeAndReturnKey(parameterSource);
        mile.setMileId(newKey.intValue());
    } else {//from w  w w  . ja v  a 2 s  .  c  o m
        this.namedParameterJdbcTemplate.update(
                "UPDATE mymiles SET catg=:catg, milestone=:milestone, user_name=:userName WHERE mileid=:mileId",
                parameterSource);
    }
}

From source file:airport.database.services.statistics.StatisticsDaoImpl.java

@Override
public void incAmoubtLendedPlane(User user) {
    SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(user);

    jdbcTemplate.update(SQL_QUERY_INC_AMOUNT_LENDED_PLANE, parameterSource);
}

From source file:net.turnbig.jdbcx.JdbcxDaoSupport.java

public <T> T queryForBean(String sql, Object beanParamSource, Class<T> mapResultToClass)
        throws DataAccessException {
    return getNamedParameterJdbcTemplate().queryForObject(sql,
            new BeanPropertySqlParameterSource(beanParamSource), getBeanPropsRowMapper(mapResultToClass));
}

From source file:com.pet.demo.repository.jdbc.JdbcOwnerRepositoryImpl.java

public void save(Owner owner) throws DataAccessException {
    BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner);
    if (owner.isNew()) {
        Number newKey = this.insertOwner.executeAndReturnKey(parameterSource);
        owner.setId(newKey.intValue());//from  ww  w.  j a v  a 2  s . c o  m
    } else {
        this.namedParameterJdbcTemplate
                .update("UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, "
                        + "city=:city, telephone=:telephone WHERE id=:id", parameterSource);
    }
}

From source file:airport.database.services.statistics.StatisticsDaoImpl.java

@Override
public void incAmountSendMessage(User user) {
    SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(user);

    jdbcTemplate.update(SQL_QUERY_INC_AMOUNT_SEND_MESSAGE, parameterSource);
}

From source file:com.branded.holdings.qpc.repository.jdbc.JdbcOwnerRepositoryImpl.java

@Override
public void save(Owner owner) throws DataAccessException {
    BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner);
    if (owner.isNew()) {
        Number newKey = this.insertOwner.executeAndReturnKey(parameterSource);
        owner.setId(newKey.intValue());//from   www .  j av a2  s  .  com
    } else {
        this.namedParameterJdbcTemplate
                .update("UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, "
                        + "city=:city, telephone=:telephone WHERE id=:id", parameterSource);
    }
}

From source file:com.example.dfa.demo.service.DfaDemoServiceImpl.java

@Override
public Long addNewProspect(EmployeeProspectDTO employeeProspect) {
    SqlParameterSource inParams = new BeanPropertySqlParameterSource(employeeProspect);
    Number insertedRow = insertEmployeeInsertStatement.executeAndReturnKey(inParams);
    employeeProspect.setEmployeeId(insertedRow.longValue());
    Map<String, ?> result = startWorkflowSpaCall.execute(inParams);
    Long dfaWorkflowId = converter.convert(result.get("dfaWorkflowId"), Long.class);
    employeeProspect.setDfaWorkflowId(dfaWorkflowId);
    return dfaWorkflowId;
}

From source file:airport.database.services.statistics.StatisticsDaoImpl.java

@Override
public void incAmountEntry(User user) {
    SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(user);

    jdbcTemplate.update(SQL_QUERY_INC_AMOUNT_ENTRY, parameterSource);
}