Spring @Transactional(readOnly=true) & MySQL Replication
When using the com.mysql.jdbc.ReplicationDriver with @Transactional annotations, you may encounter some strange behavior. I recently learned that marking a method read-only will stop it from writing anything to the database but w/o throwing any kind of error message.
It appears that with Hibernate, the read only transaction advice will cause it to set the connection to never flush. So instead of giving an error message the session will end w/o commiting the write.
I found this behavior surprising and thought I would share it in case anyone else is using this driver for transactions.
Written by Sam Thomas
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#