org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
here my code :
The exception occures only on save operation, it wont happens on another operation.
Any hints or suggestion would be appreciate.
The problem is that you defined your transactional annotation in the interface instead of the implementation.
These annotations aren't inherited by your implementing class.
The above should be defined in your implementation.
posted 10 years ago
This weird situation is caused by OpenSessionInViewFilter.
Check this link Exception reason
as Juergen Hoeller said
Invoking HibernateTemplate's save/update/delete methods on a Spring-managed Session in FlushMode.NEVER is potentially dangerous: It means that you are:
* either doing this in a Spring-managed read-only transaction, which will never flush the Hibernate Session, i.e. never flush your save/update/delete calls. The new check makes you aware that you won't persist your changes in that situation.
* or working with some other thread-bound Session in FlushMode.NEVER, for example the OpenSessionInViewFilter. If you're overriding closeSession there to flush after view rendering, you should override getSession too, setting the Session to FlushMode.AUTO.
so i create another filter to force that FlushMode is AUTO/COMMIT
here my code :
and I change web.xml configuration as below :
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad: