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

I understand the difference between copy vs. deepcopy in the copy module. I've used
Well, the title more or less says it all. I sort of understand what
As the title says... are they considered different languages? For example if you've written
As the title says, I want to know if it is be possible to
A friend of mine is getting this error on ALL of her websites. They
I'm using NSFetchedResultsController pretty much out-of-box in the way that the documentation describes. Here
I have numerous buttons that go to different views on my main page and
I have used a few different tooltip plugins over the years, but I think
I was reading up on this javascript tutorial: http://www.switchonthecode.com/tutor...ccordion-menus Basically, it shows you how

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.