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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:31:56+00:00 2026-05-30T19:31:56+00:00

I have a play model called JobStatus and it’s just got one property, an

  • 0

I have a play model called “JobStatus” and it’s just got one property, an enum with a JobState, (Running/notRunning).

The class extends model and is implemented as a singleton. You call it’s getInstance() method to get the only record in the underlying table.

I have a job that runs every month and in the job I will toggle the state of the JobStatus object back and forth at various times and call .save().

I’ve noticed it isn’t actually saving.

When the job starts off, it’s first line of code is

JobStatus thisJobStatus = jobStatus.getInstance();
...// exit if already running

thisJobStatus.JobState = JobState.Running;
thisJobStatus.save()

then when the job is done it will change the status back to NotRunning and save again.

The issue is that when I look in the MySql database the actual record value is never changed.

This causes a catastrophic failure because when other nodes try to run the job they check the state and since they’re seeing it as NotRunning, they all try to run the job also.

So my clever scheme for managing job state is failing because the actual value isn’t getting commited to the DB.

How do I force Play to write to the DB right away when I call .save() on a model?

Thanks
Josh

  • 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-30T19:31:58+00:00Added an answer on May 30, 2026 at 7:31 pm

    try adding this to your JobStatus and call it after save.

    public static void commit(){
        JobStatus.em().getTransaction().commit();
        JobStatus.em().getTransaction().begin();
        JobStatus.em().flush();
        JobStatus.em().clear();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models: Play and PlayParticipant , defined (in part) as: class PlayParticipant(models.Model):
I have the following classes: import play.db.ebean.Model; import javax.persistence.*; @Entity public class A extends
I have a question about Android Market/Google Play license model for paid applications. First
i have a simple question. if i use play.db.ebean.Model to have my Model extend
Hi So I have created a quick table: package models; import javax.persistence.*; import play.db.ebean.Model;
I have created a play application and have some models. One of them contains
I have two Play framework web applications running on my system on ports 9001
I have the following form: class ModuleItemForm2(forms.ModelForm): class Meta: model = Module_item fields =
In my ruby on rails project in model, I have some of definition. class
I have a simple User model whose fields are annotated with play validation annotations

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.