1

Considering a use of JPA inside a Java EE container (or Spring container):

Is it right to say that a main difference between JTA and Resource-local transaction is (except concept of first-level caching managed by container using JTA):

JTA opens a JDBC transaction only as soon as entityManager flushes one or more entities and closes it when commit is executed (manually or at the end of transactional method).

Whereas a block of code within a Resource-local transaction opens a JDBC transaction as soon as a first operation is sent to the database. There is no concept of persistence delay in order to optimize access to datatabase' like JTA does.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Mik378
  • 21,881
  • 15
  • 82
  • 180
  • Possibly duplicate of [What is the difference between JTA and a local transaction?](http://stackoverflow.com/questions/9552718/what-is-the-difference-between-jta-and-a-local-transaction) – Shehzad May 04 '12 at 15:32
  • @Shehzad I've just renamed the title in order to be more precised. – Mik378 May 04 '12 at 15:39
  • You're confusing JTA and JPA. These are two completely different things. – JB Nizet May 04 '12 at 15:42
  • In both cases I relate usage of entitymanager, so JPA for instance. But an entityManager can be managed through both associated transactions types : JTA and Resource-local – Mik378 May 04 '12 at 15:45
  • 4
    First-level caching has nothing to do with JTA, and everything to do with JPA. Whether you use JTA or not, JPA uses a first-level cache. The main difference between JTA and resource-local transactions is that JTA transactions can enlist several transactional resources, whereas resource-local transactions are local to a single resource (hence their name). JTA doesn't delay or optimize anything. – JB Nizet May 04 '12 at 15:52
  • @JB Nizet I understand, very clear, thanks :) – Mik378 May 04 '12 at 15:55

0 Answers0