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

  • SEARCH
  • Home
  • 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 6987837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:59:26+00:00 2026-05-27T18:59:26+00:00

I am working on a grails web-app The application is running on a very

  • 0

I am working on a grails web-app

The application is running on a very slow network and is being accessed by old and slow client pc’s that are running IE 6. The database connection is extremely slow and the db is over worked. So minimizing db calls and data being passed back and forth is a priority

I know that using session scope is not best practice. In this case i thought it would be best. Considering that all my pages require the same set of objects and this would have them fetched many times over

So i placed my object in the session scope session.obj = obj

It works fine with one issue
Because the system is so slow multiple clicks on a link to a web page (controller/action) are possible.

When this happens i get a error on some cases
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions

the error happens on this code

if (!obj?.isAttached()) {
   obj?.attach()
}

i have to attach the object back to the hibernate session so i can lazy load related objects
i don’t want to eager fetch (probably a solution)
i seems that the error is cause when the object is being attached more then once. the condition does not seem to block the problem. Is it a race condition ?

i just would like to know if anyone has a solution to this problem or know the cause

thank you

  • 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-27T18:59:27+00:00Added an answer on May 27, 2026 at 6:59 pm

    If you want to avoid round-trips to the database and still code in a safe way, without having to deal with attaching/detaching objects to/from the Hibernate session, what you should do is use a Hibernate second-level cache. This would enable to transparently cache the often used entities, their associations, and even result of queries that are often executed.

    The caching would also be more efficient and use less memory, because it would be shared across all the user sessions. And of course, it would be safer, because you wouldn’t ever have stale entities in the HTTP session.

    Definitely the way to go, IMO.

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

Sidebar

Related Questions

I'm working on a Grails web app that would be similar in access patterns
I'm integrating Gigya with a web app running Acegi. I have it working that
I am working on a web application (using Grails) which will generate a gift
Hey all- I'm working on some web flows for a Grails app we're building.
I am working with a Grails web application and I get so many strange
I am working on a backend Grails application that pulls information periodically from a
I'm working on a Grails application that would handle video games But more than
I am developing a web-application in grails.In that I have implemented video's playing option.For
I have been trying for 4 days to get app-engine and grails working together
I'm working on a Grails application. There is a domain class participant - within

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.