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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:41:06+00:00 2026-05-28T19:41:06+00:00

I have a simple User Account application in which the user is able to

  • 0

I have a simple User Account application in which the user is able to change his details.

Updating the Database

The Managed Bean’s method which takes the form parameters and calls the Service method:

public String changeDetails(){
    Date date = DateUtil.getDate(birthDate);
    Integer id = getAuthUser().getId();
    UserDetail newDetails = new UserDetail(id, occupation, date, originCity, residenceCity, description);

    EntityTransaction transaction = getTransaction();
    userService.updateDetail(newDetails);
    transaction.commit();

    return null;
}

The Service Method:

public boolean updateDetail(UserDetail newDetails) {
    boolean ok = true;
    if (newDetails != null) {
        UserDetail user = readDetail(newDetails.getId());

        user.setOccupation(newDetails.getOccupation());
        user.setOriginCity(newDetails.getOriginCity());
        user.setResidenceCity(newDetails.getResidenceCity());
        user.setBirth(newDetails.getBirth());
        user.setDescription(newDetails.getDescription());
    }
    return ok;
}

Fetching data from DB

@PostConstruct
public void init(){
    userService = new UserService();
    sessionController.setAuthUser(userService.read(getAuthUser().getId()));
    originCity = getAuthUser().getUserDetail().getOriginCity();
    residenceCity = getAuthUser().getUserDetail().getResidenceCity();
    occupation = getAuthUser().getUserDetail().getOccupation();
    birthDate = DateUtil.getStringDate(getAuthUser().getUserDetail().getBirth());
    description = getAuthUser().getUserDetail().getDescription();
}

The problem is that the behavior of this code is different. Sometimes I obtain the desired result: once I submit the new details and call the @PostConstruct init () the new details are printed. Some other times the old details are printed even though the DB entry is updated.

Conclusion: Sometimes the JPA brings me different result from what is in the DB. I guess that this results consist of data from the Persistance Context, data which isn’t updated. Is there a way in which I can be sure that the JPA always brings the data directly from the DB? Or is there something I’m missing?

  • 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-28T19:41:07+00:00Added an answer on May 28, 2026 at 7:41 pm

    If you are using JPA 2 then @Cacheable(false) on your entity definition should make it read from the DB every time.

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

Sidebar

Related Questions

I have a simple application in which I need to let the user select
I have a simple databasescheme: User, Account. User has 1-to-many relationship with Account. I
I have a simple Desktop Facebook application that allows the user to retrieve some
I have a simple table view which is editable. All I need the user
I have a simple database with two tables. Users and Configurations. A user has
I am working on simple application which creates google calendar (under it's own account).
If I have a User class, and his account can be suspended by adding
Hi i have develop an android application in which i want to prevent user
I already have a User table in my primary application database with an email
I have a simple user production report where daily quotas are tracked. The sql

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.