开发者

Spring JdbcTemplate returns empty result when there should be a valid result

I'm using SimpleJdbcDaoSupport object to access DB resources. I have a query which is frequently executed against the database to locate a record with a specific key. for some reason after executing the same query several times I start to get an empty result even though the record exists in the database.

Any ideas what can cause this behavior?

daoSupport.getJdbcTemplate().query(this.getConsumerTokenQueryStatement(),params, this.rowMapper); 
 public static class TokenServicesRowMapper implements RowMapper {  
   public Object mapRow(ResultSet rs, int rowNum) throws SQLException { 
     DefaultLobHandler lobHandler = new DefaultLobHandler(); 
     r开发者_开发知识库eturn lobHandler.getBlobAsBytes(rs, 1); 
   } 
}


If this is not related to your code one reason can be the fact that another transaction is doing something (like an update) to the row you search and due do the isolation between transactions you cannot see your row. One transaction can change but not commit your row yet while in the same time the other one is searching for it but as it can only see committed rows it does not see your row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜