Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails 行被登录事件侦听器中的另一个事务错误更新或删除?_Grails_Spring Security - Fatal编程技术网

Grails 行被登录事件侦听器中的另一个事务错误更新或删除?

Grails 行被登录事件侦听器中的另一个事务错误更新或删除?,grails,spring-security,Grails,Spring Security,我有一个简单的spring安全登录事件监听器,注册为 class LoginEventListener implements ApplicationListener<InteractiveAuthenticationSuccessEvent> { //deal with successful login void onApplicationEvent(InteractiveAuthenticationSuccessEvent event) {

我有一个简单的spring安全登录事件监听器,注册为

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])