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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:49:48+00:00 2026-05-15T14:49:48+00:00

Title says it all: What is the difference between a UserTransaction and an EntityTransaction

  • 0

Title says it all: What is the difference between a UserTransaction and an EntityTransaction?

My rudimentary understanding is that UserTransaction is used when JTA is required (e.g. to do queries on mulitple things), and that EntityTransaction is used when JPA only is required (e.g. when the query is atomic).

Is that the only difference between the two or is there more to it than that?

  • 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-15T14:49:48+00:00Added an answer on May 15, 2026 at 2:49 pm

    My rudimentary understanding is that
    UserTransaction is used when JTA is
    required (e.g. to do queries on
    mulitple things), and that
    EntityTransaction is used when JPA
    only is required (e.g. when the query
    is atomic).

    That’s basically right, but your description of “multiple things” and “atomic” is a bit strange. JTA allows the developper to use distributed transaction to perform changes on multiples resources (database, JMS broker, etc.) atomically (all-or-nothing). If only one resource is accessed (e.g. one single database), you don’t need JTA, but the transaction is still atomic (all-or-nothing). That’s for instance the case when you use a regular JDBC transaction on one database.

    Considering UserTransaction vs. EntityTransaction:

    • If JPA is use stand-alone, you use EntityTransaction to demarcate the transaction yourself.
    • If JPA is used within a managed environment where it integrates with JTA, you use UserTransaction. The EntityManager hooks itself into the JTA distributed transaction manager. The only subtlety I’m aware of considers the flush of the changes. When EntityTransaction is used, JPA know it needs to flush the changes. If transaction are controlled using UserTransaction, it needs to register a callback using JTA registerSynchronization, so that the changes are flushed to the database before the transaction completes. If you use EJB with CMT (container managed transaction), you don’t even need to use UserTransaction: the app server starts and stops the transactions for you.

    Related questions:

    • What is difference between UserTransaction and EntityManager.getTransaction() (duplicate)
    • XA and non-XA datasource with Spring/Hibernate (related)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Title more or less says it all. Specifically, I've become increasingly annoyed that in
Question title says it all really - a lot slower than VS2005, with a
The title pretty much says it all. Some caveats are: I need to be
The title pretty much says it all. I'm using a TClientDataset to store an
The title pretty much says it all. When I'm doing some reflection through my
I think the title pretty much says it all... I'm looking to implement an
Title says what i'm trying to do. I can successfully generate an assembly if
Title says it mostly. I want to add a simple extension method to the
As title says, how do I call a java class method from a jsp,
Just what the title says, I need to change the password for an existing

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.