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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:44:42+00:00 2026-06-09T02:44:42+00:00

I am just creating a settings page where a user can change his user

  • 0

I am just creating a settings page where a user can change his user name. The strange thing is I am using the same finder Method for displaying it in the main view and in the form but the objects are not related to each other.

The side effect is now, if I dont enter an username and click on save. Both objects are updated. As well the display in the view which is wrong.

I just want to use in the form a seperate model. What am I doing wrong here? I thought calling “Model.find” is returning me everytime a different reference of an object, even if its the same row in the db. Is play doing some intelligent caching here?

Its quite anoying as changing the user in the form means changing all other same user objects in the view.

Action for rendering the create/edit page:

public static void index(){
        User appUser = User.findUser(SecureSocial.getCurrentUser().id);
        render(appUser);
 }

My view(which displays the current logged in username)

${models.User.findUser(user.id).username}

My model:

public static User findUser(UserId userId){
        User user = User.find("externalId = ? and provider = ?", userId.id, userId.provider.name()).first();
        return user;
}

Thanks

  • 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-09T02:44:43+00:00Added an answer on June 9, 2026 at 2:44 am

    Hibernate is backing your persistent storage. Hibernate will, for one persistent (logical) object in one Transaction, only create and keep one instance of it around for many reasons. So the behavior you describe is actually to be expected.

    For more on that, see http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/objectstate.html#objectstate-overview.

    To have two instances of your object around at the same time, you have to detach (ie. remove the link to the DB object in Hibernate’s parlance) it. Typically you detach the object which is edited, and let the object for the rendering alone.

    So you would change your controller function to detach the object which is edited:

    User.em().detach(user);

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

Sidebar

Related Questions

I'm just creating my own AboutBox and I'm calling it using Window.ShowDialog() How do
I am using MonoTouch.Dialog to create a settings-like page. The linq below creates a
I'm creating an Asp.Net program UI where users can browse and change information in
I just got a homework assignment, and it's just creating a linear search algorithm
Essentially, I am just creating two classes where one class, in this case class
How does upshot.js handles DateTime objects? As it seems its just creating normal strings
I just finished creating my first major application in C#/Silverlight. In the end the
I just finished creating a large online flex app with 43 different screens. I
I just finished creating several models and a had to separately write all of
I have just finished creating an API where the requests from the API are

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.