Grails 行被登录事件侦听器中的另一个事务错误更新或删除?
我有一个简单的spring安全登录事件监听器,注册为Grails 行被登录事件侦听器中的另一个事务错误更新或删除?,grails,spring-security,Grails,Spring Security,我有一个简单的spring安全登录事件监听器,注册为 class LoginEventListener implements ApplicationListener<InteractiveAuthenticationSuccessEvent> { //deal with successful login void onApplicationEvent(InteractiveAuthenticationSuccessEvent event) {
class LoginEventListener implements
ApplicationListener<InteractiveAuthenticationSuccessEvent> {
//deal with successful login
void onApplicationEvent(InteractiveAuthenticationSuccessEvent event) {
User.withTransaction {
def user = User.get(event.authentication.principal.id)
user.lastLoginTime = new Date() // update login time
user.save()
}
}
}
我想知道如何避免这个错误?谢谢你的帮助!谢谢 尝试使用锁
def user = User.get(event.authentication.principal.id ,[lock: true])
def user = User.get(event.authentication.principal.id ,[lock: true])