Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3336824
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:10:54+00:00 2026-05-18T00:10:54+00:00

I have a Grails app where people login through Spring Security. Their user domain

  • 0

I have a Grails app where people login through Spring Security. Their user domain is then loaded onto the session for the duration of being logged in.

I get a StaleObjectStateException when another user preforms an action that updates a counter on a user object in the database user.save(flush:true) that’s currently on another session of a logged in user

E.g. I have “User A” object on the session for logged in User A.
Then when a User B is logged in, and preforms an action to update the User A object but the version is out of sync.

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.example.User#2]

        at $Proxy12.merge(Unknown Source) 

I’ve tried merging but no luck.

I’m thinking of completely taking out the “version” property as there are so many updates on the user domain as hundreds of users would be logged in. But I don’t know what affect this would have on the consistency of the data over time.

Would swapping user.save(flush:true) to User.executeUpdate(Update viewCount where ...) solve the problem and bring more caching issues?

Or can I select specific properties that can ignore “version” when updating them.
I don’t really understand whats going on though with this example.
http://grails.1312388.n4.nabble.com/GORM-setting-access-field-td1592837.html

So how can I solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:10:54+00:00Added an answer on May 18, 2026 at 12:10 am

    Solved: Basically don’t have the user domain on the session. Just the users Id. So you can load the domain when you need to use it.

    The solution is not to use a domain object inside the session. Use the id instead, and then load the object for each request that needs the user data. It’s differences introduced in spring security plugin for grails. For more info have a look here (official docs):

    http://burtbeckwith.github.com/grails-spring-security-core/docs/manual/guide/2%20Differences%20Between%20the%20Spring%20Security%20and%20Acegi%20Plugins.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grails app configured with spring-security-core and I need to allow Facebook
I have a grails app that uses the Spring-Security-Core plugin, which integrates Spring Security
My Grails app is using the Spring Security plugin. I need to login a
I have a Grails app with acegi security, and I just found some users
I have a grails 1.2 app and I want to use declarative security in
I have a grails app with a domain Restaurant and a domain Person. class
Scenario: I have a Grails app that uses Acegi security for authentication. I'm implementing
I'm coming from a Spring MVC background on a new Grails app. I have
I have a Grails app that loads its data from xml files and delivers
I'm developing a Grails App. I have about 20 Controllers right now and there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.