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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:13:40+00:00 2026-05-21T23:13:40+00:00

I am not really sure where my problem lies, as I am experimenting in

  • 0

I am not really sure where my problem lies, as I am experimenting in two areas that I don’t have much experience with: JPA and Futures (using Play! Framework’s Jobs and Promises).

I have the following bit of code, which I want to return a Meeting object, when one of the fields of this object has been given a value, by another thread from another HTTP request. Here is what I have:

    Promise<Meeting> meetingPromise = new Job<Meeting> () {
        @Override
        public Meeting doJobWithResult() throws Exception {
            Meeting meeting = Meeting.findById(id);
            while (meeting.bbbMeetingId == null) {
                Thread.sleep(1000);
                meeting = meeting.refresh();       // I tried each of these
                meeting = meeting.merge();      // lines but to no avail; I
                meeting = Meeting.findById(id); // get the same result
            }
            return meeting;
        }
    }.now();
    Meeting meeting = await(meetingPromise);

As I note in the comments, there are three lines in there, any one of which I think should allow me to refresh the contents of my object from the database. From the debugger, it seems that the many-to-one relationships are refreshed by these calls, but the single values are not.

My Meeting object extends Play! Framework’s Model, and for convenience, here is the refresh method:

/**
 * Refresh the entity state.
 */
public <T extends JPABase> T refresh() {
    em().refresh(this);
    return (T) this;
}

and the merge method:

/**
 * Merge this object to obtain a managed entity (usefull when the object comes from the Cache).
 */
public <T extends JPABase> T merge() {
    return (T) em().merge(this);
}

So, how can I refresh my model from the database?

  • 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-21T23:13:40+00:00Added an answer on May 21, 2026 at 11:13 pm

    So, I ended up cross-posting this question on the play-framework group, and I got an answer there. So, for the discussion, check out that thread.

    In the interest of having the answer come up in a web search to anyone who has this problem in the future, here is what the code snippet that I pasted earlier looks like:

    Promise<Meeting> meetingPromise = new Job<Meeting> () {         
        @Override
        public Meeting doJobWithResult() throws Exception {
            Meeting meeting = Meeting.findById(id);
            while (meeting.bbbMeetingId == null) {
                Thread.sleep(1000);
                if (JPA.isInsideTransaction()) {
                    JPAPlugin.closeTx(false);
                }
                JPAPlugin.startTx(true);
                meeting = Meeting.findById(id);
                JPAPlugin.closeTx(false);
            }
            return meeting;
        }
    }.now();
    Meeting meeting = await(meetingPromise);
    

    I am not using the @NoTransaction annotation, because that messes up some other code that checks if the request is coming from a valid user.

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

Sidebar

Related Questions

I'm not really sure if there is a single problem here or I have
Now I'm not really sure what the problem here is but it seems that
I have a problem and I'm not really sure where to start. What I
I'm not really sure what the problem is here, I have a posts table
I'm not really sure how to title this question but basically I have an
I have a number of atomic classes (Components/Mixins, not really sure what to call
I'm not really sure where my problem is but the scenario is as follows.
I am not really sure what to do in this situation. I have some
Well.. I am not really sure what that means, but my systems runs and
I am getting invalid use of group function, not really sure where the problem

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.