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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:54:45+00:00 2026-05-26T22:54:45+00:00

After finding out how to manually commit a Play! JPA transaction … I’m not

  • 0

After finding out how to manually commit a Play! JPA transaction … I’m not sure I really need to.

I have two controller actions: one that adds a website, and immediately redirects to the next one … which shows its edit form.

public static void added(String title){
    Task task= new Task();
    website.title = title;

    task.save();
    // Do I really need to commit this transaction here?
    // Note that task.id is already filled here, somehow
    // https://stackoverflow.com/questions/8169640/how-does-an-entity-get-an-id-before-a-transaction-is-committed-in-jpa-play
    JPA.em().getTransaction().commit();

    edit(task.id);
}

public static void edit(long taskId) {
    Task task = Task.find("byId", taskId).first();
    render(task);
}

Is there a need to commit the transaction before redirecting to edit()?

  • 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-26T22:54:45+00:00Added an answer on May 26, 2026 at 10:54 pm

    No. 🙂 (Though there may be situations in the future where you may need to take control of the transaction handling, this does not appear to be one of them; as you also discovered, Play! flushes the session immediately after saving, so you have access to the auto-generated PK ID. As this appears to be the only reason you were attempting this, I would let Play! do its thing and only hijack control if/when you really need to.)

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

Sidebar

Related Questions

I'm using Silverlight Beta 4 for a LOB application. After finding out today that
after googleing a bit im stuck in finding out which SWT. flags I can
I have quite a problem with finding out how to distribute the web based
I have been tasked with finding out what is causing an issue with this
after finding out that there is a bug in the UITapGestureRecognizer ( How to
updated following Dirk's suggestion After finding out about emacs' check-parens and show-parens modes in
Really not having a good week with encryption. Let me explain what I need.
After lots of attempts and search I have never found a satisfactory way to
After finding the difflib.SequenceMatcher class in Python's standard library to be unsuitable for my
I'm having a problem finding out which NSTextfield is focused. I am building a

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.