先记录一下。遇到要使用自动增长的序列时,添加数据可以先查询一下序列号,设置再插入
String s = "select nextval('seq_collection_0') ";
try {
int guid = getNamedParameterJdbcTemplate().queryForInt(s, Collections.EMPTY_MAP);
t.setGuid((long)guid);
Map<String, Object> paramMap = SCollectionRowMapper.putCollectionMap(t);
SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(getDataSource()).withTableName("s_collection_0")
.usingColumns("uid","type","remark","phone","parentid","name","luid","longitude","latitude","lasttime","guid",
"cityid","addtime","address");
return simpleJdbcInsert.execute(paramMap);
} catch (Exception e) {
return 0;
}