I battled with this problem for days. I am working on a JavaEE project running on Wildfly 26.1.3 with Java 11 and Hibernate 5.6.15.Final. Adding the following property to my persitence.xml file fixed the problem for me:
<property name="org.hibernate.flushMode" value="COMMIT" />