Title:
regression: javax.persistence.TransactionRequiredException when doing native createQuery() calls
| View in TrackerStatus/Resolution/Reason: To Test//Fixed
Reporter/Name(from Bugbase): Luis M. / ()
Created: 06/18/2019
Components: ORM Support
Versions: 2018
Failure Type:
Found In Build/Fixed In Build: all /
Priority/Frequency: Normal /
Locale/System: / Win All
Vote Count: 0
Problem Description:
If you do a native query call in acf2016 and acf11 this worked without creating native transactions. In 2018, you get an exception.
Steps to Reproduce:
{code:java}
transaction{
// delete using lowercase id convention from hibernate for identifier
var datasource = variables.orm.getEntityDatasource( arguments.entityName );
var query = variables.orm.getSession( datasource )
.createQuery( "delete FROM #arguments.entityName# where id in (:idlist)" );
query.setParameterList( "idlist", arguments.id );
count = query.executeUpdate();
}
{code}
Actual Result:
javax.persistence.TransactionRequiredException: Executing an update/delete query at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1496) at sun.reflect.GeneratedMethodAccessor172.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at coldfusion.runtime.StructBean.invoke(StructBean.java:507) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3476) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3357) at cfBaseORMService2ecfc962975903$func_CF_ANONYMOUSCLOSURE_221.runFunction(/Users/lmajano/Sites/cboxdev/coldbox-core-modules/cborm/models/BaseORMService.cfc:939) at coldfusion.runtime.Closure.invoke(Closure.java:111) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:447) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:398) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:371) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:597) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3310) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:3277) at cfBaseORMService2ecfc962975903$func$TRANSACTIONED.runFunction(/Users/lmajano/Sites/cboxdev/coldbox-core-modules/cborm/models/BaseORMService.cfc:1883) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:553) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:484) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:447) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:398) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:371) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:287) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:3928) at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:3908) at cfBaseORMService2ecfc962975903$funcDELETEBYID.runFunction(/Users/lmajano/Sites/cboxdev/coldbox-core-modules/cborm/models/BaseORMService.cfc:953) Executing an update/delete query
Expected Result:
The count of deleted objects.
Any Workarounds:
You have to add a hibernate transaction. Before in previous ACF versions, the CF transaction was enough for this query to cover it. Now it breaks
Attachments:
Comments: