Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your

Common bugs when running after ssh integration

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
What is the reason for this?

This is because after the integration of the three ssh frameworks, the dao layer mainly uses the HibernateTemplate method to operate the database, so that transactions must be added to prevent errors.

The specific solution is as follows, we can open some things in applicationContext.xml
<!--Configure Transaction Manager-->  
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">  
<property name="sessionFactory" ref="sessionFactory"></property>  
</bean>  
<!-- Turn on transaction scanning, using annotations-->  
<tx:annotation-driven transaction-manager="transactionManager"/>  

Add the following annotation to our method
@Transactional

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326056470&siteId=291194637