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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:39:27+00:00 2026-06-13T06:39:27+00:00

I am experimenting with JPA in standalone mode (backed by Hibernate). I’ve noticed that

  • 0

I am experimenting with JPA in standalone mode (backed by Hibernate).
I’ve noticed that the following code succeeds in changing the database value to “garbled”:

A a = em.find(A.class, 1);
a.setA1("garbled");
entityTransaction.begin();   // line 3
entityTransaction.commit();  // line 4
em.close();                 

There is no other transaction begin() before line 3.
The language used in the API spec for EntityTransaction would seem to indicate otherwise or perhaps something is a bit counter-intuitive in the model of demarcating a JPA entity transaction with begin() and commit()? Note that lines 3 and 4 are necessary as commenting them out does not change the database value.

  • 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-13T06:39:28+00:00Added an answer on June 13, 2026 at 6:39 am

    a in your example is a managed entity associated with em instance, can be modified outside a transaction boundary and will be persisted as part of committing a transaction from the same entity manager instance. The transaction boundaries only define what goes into the database when the transaction is committed and what changes made to the DB get reverted when the transaction fails. Assuming that you failed the transaction in your example, a would still have the changes made, it is only that the database will not have these changes and so are not visible to others.

    If you were expecting that managed entities should not be modifiable outside the transaction boundaries, or any changes to them outside the transaction boundaries shouldn’t get persisted, then that is not true. The life cycle of a managed entity is tied with its entity manager.

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

Sidebar

Related Questions

When experimenting with (embedded) Apache Derby DB, I noticed that a fresh database, with
Im experimenting with the following code private void timer1_Tick(object sender, EventArgs e) { Thread
After experimenting with an iterator block I noticed the generated IL code is not
When experimenting with Cassandra I've observed that Cassandra writes to the following files: /.../cassandra/commitlog/CommitLog-<id>.log
I'm experimenting with JPA queries but keep getting an error on the following query
After experimenting with scripts on facebook.com, I noticed that for a couple of minutes
From experimenting with the r.js optimizer, it seems that there is no way for
While experimenting a bit with C++ templates I managed to produce this simple code,
I'm using spring mvc 3.0 with eclipselink and jpa and I'm experiencing following issue:
Experimenting with Swing, I learnt that there are two ways of using JOptionPane and

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.