AOP Configuration Services error: javax.persistence.TransactionRequiredException: no transaction is in progress

The transaction configuration is as follows:

Methods of serviceimpl class

Error report

javax.persistence.TransactionRequiredException: no transaction is in progress
	at org.hibernate.internal.AbstractSharedSessionContract.checkTransactionNeededForUpdateOperation(AbstractSharedSessionContract.java:409)
	at org.hibernate.internal.SessionImpl.checkTransactionNeededForUpdateOperation(SessionImpl.java:3602)
	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1483)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1479)  

Note: the method name of serviceimpl is find * (); Has been configured as & lt; tx:method name=”find*” propagation=”SUPPORTS”/>

Supports: supports the current transaction. If there is no current transaction, it will be executed in non transaction mode

I don’t understand why javax.persistence.transactionrequiredexception: no transaction is in progress

Later & lt; tx:method name=”find*” propagation=”SUPPORTS”/> Change to & lt; tx:method name=”find*” propagation=”SUPPORTS” read-only=”true”/> Problem solving

Read only applications:

If you execute a single query at a time, it is unnecessary to enable transaction support. The database supports read consistency during SQL execution by default
if you execute multiple query statements at one time, such as statistical query and report query, in this scenario, multiple SQL queries must ensure the overall read consistency, otherwise, after the previous SQL query and before the next SQL query, the data is changed by other users, then the whole statistical query will appear the read data inconsistent state, and at this time, the read data is inconsistent, Transaction support should be enabled
[note that multiple queries are executed at a time to count some information. In this case, read-only transactions are used to ensure the overall consistency of the data]

Similar Posts: