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 8956739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:50:52+00:00 2026-06-15T14:50:52+00:00

Im having a hard time figuring out why something is happening in my application.

  • 0

Im having a hard time figuring out why something is happening in my application.
Using spring and Hibernate and struts2 there is some really strange stuff i noticed during debugging.

I have a user-form, where a user can edit his information. When this form is submitted, the controller’s save() method should do some stuff and save the user.

The strange thing is, that before I do anything in the controller, i want to find information about who is doing this change. So i fetch a User-object from the db based on the Id of whoever is submitting the form. But when this user-object is fetched. Then automaticly the user in the form is submitted…
Im fetching the user like this:

User createdByUser = (User) getHibernateTemplate().find("from User u where u.username=?", username).get(0);

So apparantly some mechanism is auto-committing my user.
Most of the time, my createdByUser is the same user as the submitted user. Could there be that hibernate detects this and somehow tries to synchronize the db?

  • 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-06-15T14:50:53+00:00Added an answer on June 15, 2026 at 2:50 pm

    Probably it’s because you are making changes on managed entity. So the changes gets synchronized with the database & the next time you fetch that entity, you are getting the entity with changes reflected, implicitly.

    Either after performing search, you can clear the persistence context to detach all the underlying entities or can detach the single entity explicitly from the session.

    From documentation :

    clear() : Completely clear the session. Evict all loaded instances and
    cancel all pending saves, updates and deletions. Do not close open
    iterators or instances of ScrollableResults.

    evict(object) : Remove this instance from the session cache. Changes to the
    instance will not be synchronized with the database. This operation
    cascades to associated instances if the association is mapped with
    cascade=”evict”.

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

Sidebar

Related Questions

Im having a really hard time figuring out how to specify a good search
Git noob here. Having a hard time figuring out why git shows some files
I am having a hard time figuring out some things about how Core Data
I am new here, but I am having hard time figuring out how to
Having a hard time figuring out why this alert code is being called once
Having a hard time figuring out the best way to do this... I have
I am having a hard time figuring out how to get cascading drop down
I am having a hard time figuring out what flags to pass to g++
I am having a hard time figuring out how to show an Image (or
I am having a hard time figuring out good reasons for the dependency property.

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.