certain EntityManager operations (e.g. StoredProcedureQuery.execute()) should rollback the TX for certain exceptions
Description
follows up on
relates to
Activity
Steve Ebersole November 3, 2015 at 9:59 PM
Thanks Scott.
Scott Marlow November 3, 2015 at 9:18 PM
Javadoc in JPA 2.1 section 3.1.1 mentions that a IAE will be thrown. Also see additional quote below from text following javadoc that explains what happens when runtime exceptions are thrown (other than LockTimeoutException):
/**
* Create an instance of Query for executing a named query
* (in the Java Persistence query language or in native SQL).
* @param name the name of a query defined in metadata
* @return the new query instance
* @throws IllegalArgumentException if a query has not been
*
defined with the given name or if the query string is
*
found to be invalid
*/
public Query createNamedQuery(String name);
Runtime exceptions thrown by the methods of the EntityManager interface other than the Lock-
TimeoutException will cause the current transaction to be marked for rollback if the persistence
context is joined to that transaction.
This also came up in https://hibernate.atlassian.net/browse/HHH-8837#icft=HHH-8837
Steve Ebersole November 3, 2015 at 8:22 PM
Scott, I am working on https://hibernate.atlassian.net/browse/HHH-8996#icft=HHH-8996 which claims we are being overly aggressive in one cases in terms of marking a transaction for rollback only stemming from this issue.
Specifically a call to EntityManager#createNamedQuery(String)
. This change reverted a previous fix to not mark the transaction for rollback only when this situation happens; the previous fix did not include a test case unfortunately which is why we did not see it.
Anyway, can you point out the section in the spec where it says that calling EntityManager#createNamedQuery(String)
where that name is not known is supposed to result in the transaction being marked for rollback?
Scott Marlow September 6, 2013 at 10:29 PM
I think that https://github.com/hibernate/hibernate-orm/pull/594 will cover what is expected for https://hibernate.atlassian.net/browse/HHH-8442#icft=HHH-8442
Steve Ebersole September 6, 2013 at 10:07 PM
Scott, is there still more to do here?
StoredProcedureQueryImpl probably needs something like:
catch ( HibernateException he) { entityManager().throwPersistenceException( he ); }