Search in sources :

Example 1 with UpdateRowHandler

use of org.sagacity.sqltoy.callback.UpdateRowHandler in project sagacity-sqltoy by chenrenfei.

the class DemeServiceImpl method updateFetch.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.sagacity.sqltoy.demo.service.DemoService#updateFetch()
	 */
@Override
public List updateFetch() throws Exception {
    StringBuilder query = new StringBuilder("SELECT STAFF_ID, STAFF_CODE, ORGAN_ID, STAFF_NAME, ENGLISH_NAME, SEX_TYPE,");
    query.append("LINK_PHONE, BIRTHDAY, DUTY_DATE, OUT_DUTY_DATE, POST, PHOTO, EMAIL, IS_VIRTUAL, OPERATOR, OPERATE_DATE, ENABLED ");
    query.append(" FROM SYS_STAFF_INFO where SEX_TYPE=:sexType");
    // String sql =
    // "select t.TRIGGER_ID, t.MANUAL_END, t.STATUS from cron_trigger t where t.STATUS in (:status) ";
    QueryExecutor queryExecutor = new QueryExecutor(query.toString(), new String[] { "sexType" }, new Object[] { "F" });
    List result = sqlToyLazyDao.updateFetch(queryExecutor, new UpdateRowHandler() {

        @Override
        public void updateRow(ResultSet rs, int index) throws SQLException {
            rs.updateString("LINK_PHONE", "13918799460");
            rs.updateString("ENGLISH_NAME", rs.getString("STAFF_NAME") + "EN");
        }
    });
    for (int i = 0; i < result.size(); i++) {
        System.err.println(((List) result.get(i)).get(0));
        System.err.println(((List) result.get(i)).get(3));
    }
    // );
    return result;
}
Also used : SQLException(java.sql.SQLException) QueryExecutor(org.sagacity.sqltoy.executor.QueryExecutor) ResultSet(java.sql.ResultSet) UpdateRowHandler(org.sagacity.sqltoy.callback.UpdateRowHandler) List(java.util.List)

Aggregations

ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 UpdateRowHandler (org.sagacity.sqltoy.callback.UpdateRowHandler)1 QueryExecutor (org.sagacity.sqltoy.executor.QueryExecutor)1