简单的Mysql选择行不一致。我无法弄清楚为什么。是我还是mysql?

时间:2012-12-03 09:13:17

标签: mysql grails

我的Grails应用程序进行了一个非常简单的调用,以查找登录用户的详细信息。基本上就是这样:

select id, username, password, firstname, lastname from Person where id=3;

有些时候得到一个结果,有时候没有。我一直在分析正在发送的sql,这对我来说没有意义。一个请求将找到Person,而后续请求将不会。下面的日志跟踪线程ID,会话ID和登录用户。我知道要求人们查看我的SQL查询日志并不是很好,但我希望我已经设法在下面清楚地说明了我所看到的内容。

2701 [INFO] 2012-12-03 02:19:02,136 audit [T-82] [23212190391C07976A2CC568F06A780A] [cb18b110954f4476b80c2@stratus5.com] 3. 
Connection.prepareStatement(select person0_.id as id4_0_, person0_.version as version4_0_, 
person0_.account_expired as account3_4_0_, person0_.account_locked as account4_4_0_, 
person0_.created_date as created5_4_0_, person0_.email_hash as email6_4_0_, person0_.enabled as enabled4_0_, person0_.first_name as first8_4_0_, 
person0_.last_name as last9_4_0_, person0_.`password` as password10_4_0_, person0_.password_expired as password11_4_0_, person0_.tmp_password as tmp12_4_0_, 
person0_.username as username4_0_ from person person0_ where person0_.id=?)     

2702 [INFO] 2012-12-03 02:19:02,137 audit [T-82] [23212190391C07976A2CC568F06A780A] 
[cb18b110954f4476b80c2@stratus5.com] 3. PreparedStatement.setLong(1, 1160)

2749 [DEBUG] 2012-12-03 02:19:02,278 SignUpApiController [T-82]
[23212190391C07976A2CC568F06A780A] [cb18b110954f4476b80c2@stratus5.com] 
user: com.stratus5.auth.Person : 1160

280 [INFO] 2012-12-03 02:15:32,143 audit [T-160] [23212190391C07976A2CC568F06A780A] [cb18b110954f4476b80c2@stratus5.com] 5. Connection.prepareStatement(select person0_.id as id4_0_, person0_.version as version4_0_, 
 person0_.account_expired as account3_4_0_, 
 person0_.account_locked as account4_4_0_, 
 person0_.created_date as created5_4_0_, person0_.email_hash as email6_4_0_, 
 person0_.enabled as enabled4_0_, person0_.first_name as first8_4_0_, 
 person0_.last_name as last9_4_0_, person0_.`password` as password10_4_0_, 
 person0_.password_expired as password11_4_0_, person0_.tmp_password as tmp12_4_0_, 
 person0_.username as username4_0_ from person person0_ 
 where person0_.id=?) 

281 [INFO] 2012-12-03 02:15:32,143 audit [T-160] [23212190391C07976A2CC568F06A780A] 
[cb18b110954f4476b80c2@stratus5.com] 5. PreparedStatement.setLong(1, 1160) 

313 [DEBUG] 2012-12-03 02:15:32,939 SignUpApiController [T-160] 
[23212190391C07976A2CC568F06A780A] [cb18b110954f4476b80c2@stratus5.com] 
Current user: null

以下是一些代码提取,如果他们有所帮助:

def principalId = new Long(springSecurityService.getPrincipal().id)
def p = Person.get(principalId)
log.debug "Current user: $p"

我刚刚使用springSecurityService.currentUser并且看到了相同的错误。我改变只是故意调用Person.get,基于假设问题可能出现在springSecurityService中,但现在看起来非常不可能。

0 个答案:

没有答案