javax.persistence.TransactionRequiredException: Executing an update/delete query in Hibernate

Solution Verified - Updated -

Issue

  • Executing an "update" query outside of a transaction using the code below was possible in Hibernate 5.1:

    entityManager.createNativeQuery("delete from Employee").executeUpdate();
    
  • After moving from JBoss EAP 7.1 / Hibernate 5.1 to JBoss EAP 7.2 / Hibernate 5.3, encountering the failure below:

    ... javax.persistence.TransactionRequiredException: Executing an update/delete query
        at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1586)
        ...
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.2
  • Hibernate 5.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content