certain EntityManager operations (e.g. StoredProcedureQuery.execute()) should rollback the TX for certain exceptions

Description

org.hibernate.exception.SQLGrammarException: could not prepare statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:91)
at org.hibernate.procedure.internal.ProcedureCallImpl.buildOutputs(ProcedureCallImpl.java:299)
at org.hibernate.procedure.internal.ProcedureCallImpl.getResult(ProcedureCallImpl.java:270)
at org.hibernate.jpa.internal.StoredProcedureQueryImpl.outputs(StoredProcedureQueryImpl.java:177)
at org.hibernate.jpa.internal.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:194)

StoredProcedureQueryImpl probably needs something like:

3.10.7 Query Execution
...
Runtime exceptions other than the NoResultException, NonUniqueResultException, QueryTimeoutException, and LockTimeoutException thrown by the methods of the Query, TypedQuery, and StoredProcedureQuery interfaces other than those methods specified below cause the current transaction to be marked for rollback if the persistence context is joined to the transaction. On database platforms on which a query timeout causes transaction rollback, the persistence provider must throw the PersistenceException instead of the QueryTimeoutException.

Runtime exceptions thrown by the following methods of the Query, TypedQuery, and StoredProcedureQuery interfaces do not cause the current transaction to be marked for rollback: getParameters, getParameter, getParameterValue, getOutputParameterValue, getLockMode.

Runtime exceptions thrown by the methods of the Tuple, TupleElement, and Parameter interfaces do not cause the current transaction to be marked for rollback

Environment

None

Status

Assignee

Scott Marlow

Reporter

Scott Marlow

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure