hibernate保存数据和调用存储过程数据事务不同步的问题
保存数据:
AaaTest aaaTest = new AaaTest();
aaaTest.setId(id);
aaaTest.setName(name);
aaaTest.setAddress(address);
this.baseDao.save(aaaTest);
QueryHelper helper = new QueryHelper();
helper.append(" from AaaTest");
List<AaaTest> l = (List<AaaTest>) baseDao.getList(helper);
调用存储过程:
//调存储过程
Connection conn = null;
CallableStatement cs = null;
ResultSet rs = null;
try {
conn = baseDao.getCurrentSession().connection();
cs = conn.prepareCall("{ call P_AAA_TEST(?,?,?) }");
cs.setInt(1, 1);
cs.registerOutParameter(2, Types.INTEGER);
cs.registerOutParameter(3, OracleTypes.CURSOR);
cs.execute();
int flag = cs.getInt(2);//返回的int
rs = (ResultSet) cs.getObject(3);
List<Map<String, Object>> list =CommonUtil.convertList(rs); //本地记录不存在,主机存在的对账记录
System.err.println("条数"+list.size());
for (Map<String, Object> map : list) {
System.err.println(map.get("name"));
}
}catch(Exception e){
e.printStackTrace();
}
发现一个问题,刚刚save的数据用存储过程查不出来,在保存数据和调用存储过程之间,加入查询代码(红色),居然可以了,为什么呢?