users@glassfish.java.net

Re: JPA (TopLink Implementation) transaction rollback behaviour

From: <glassfish_at_javadesktop.org>
Date: Fri, 18 Jan 2008 10:24:54 PST

The transaction IS NOT active. The exception from the persist(D) blew out the transaction and killed it, so there's no need to rollback. I don't know if it's a feature or a bug (guess it depends on the use case), but exceptions within JPA nuke the entire transaction.

For example, one thing you could do in straight sql, but not in JPA, is the classic "insert first" check for a duplicate, and then update if the insert fails.

With JPA, that idiom won't work as the insert (assuming a duplicate) will destroy the transaction.

That's why you'll get that error.
[Message sent by forum member 'whartung' (whartung)]

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