users@glassfish.java.net

Re: EntityTransaction vs UserTransaction

From: <glassfish_at_javadesktop.org>
Date: Sat, 21 Feb 2009 23:49:55 PST

Here is what "Enterprise JavaBeans, 3.0" by Bill Burke, Richard Monson-Haefel, Print ISBN-10: 0-596-00978-X says:

=========================================================

5.6. Resource Local Transactions

An entity manager's persistence context is usually managed by a JTA transaction in a Java EE environment. [b]When running in a non-Java EE environment, JTA is not available, so the Java Persistence API specification has provided a transaction-like API through
the EntityTransaction interface[/b]. You can obtain access to an Entity-Transaction through the EntityManager.getTransaction( ) operation:
public interface EntityTransaction {
public void begin( );
public void commit( );
public void rollback( );
public boolean isActive( );
}
The begin( ) method throws an IllegalStateException if there is already an active EntityTransaction. The commit( ) and rollback( )
methods throw an IllegalState-Exception if there is not an active transaction.

[b]It is possible for a vendor implementation to allow the use of the EntityTransaction API
Java EE environment, but the application developer is encouraged to use JTA.[/b]
[Message sent by forum member 'pobeditel' (pobeditel)]

http://forums.java.net/jive/thread.jspa?messageID=333227