/**
* 基于主键的查询方法 根据给出的主键查询一个业务并返回
*
* @param key
* @return
*/
public List findByPrimaryKey(String key) {
logger.debug("finding service by primary key");
try {
return getJdbcTemplate().query(
"SELECT serviceid,contenttype,templatetext FROM table where serviceid='"+key+"'",
new RowMapper() {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
String serviceid = rs.getString(1);
String contenttype = rs.getString(2);
String templatetext = lobHandler.getClobAsString(rs, 3);
return new SerVConTemPBean(serviceid, contenttype, templatetext);
}
});
} catch (RuntimeException re) {
logger.warn("finding service by primary key failed", re);
throw re;
}
}
/**
* 根据业务主键更新信息
* @param key
* @param params
* @param types
* @return
*/
public void updateContentByPrimaryKey(final String key,final String templatetext) {
logger.debug("update service content by content template primary key");
try {
getJdbcTemplate().execute(
"update table set templatetext=? where serviceid=?",
new AbstractLobCreatingPreparedStatementCallback(this.lobHandler)
{protected void setValues(PreparedStatement ps,
LobCreator lobCreator) throws SQLException {
lobCreator.setClobAsString(ps, 1, templatetext);
ps.setString(2, key);
}
}
);
} catch (RuntimeException re) {
logger.warn("update service by service primary key failed", re);
throw re;
}
}