Why this Hibernate MySQL Connection is read-only?

前端 未结 2 1883
暗喜
暗喜 2021-02-01 04:07

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

相关标签:
2条回答
  • 2021-02-01 04:53

    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.

    0 讨论(0)
  • 2021-02-01 04:59

    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

    0 讨论(0)
提交回复
热议问题