I have an application using Spring with Hibernate on a MySQL database. For some reason, as of the last few days, anytime I try to persist any objects to my database I am getting
After about 3 hours of horrible debugging I now know what's going on. I have a service-level method that I also have an "around" advice on. The service-level method is annotated with @Transactional(readOnly=true)
, however, I have another service in my advice that was annotated with @Transactional(readOnly=false)
.
My aspect (or advice) is using the same DAO objects as my normal service-layer, so when I called sessionFactory.getCurrenctSession()
it's giving me back the session that was created for my Read-Only Service-level method. Now, I have to re-architect.
This looks like the bug they have in MySQL Connector/J for versions up to 5.1.6: http://bugs.mysql.com/bug.php?id=38747
Make sure that version is your case at least 5.1.7