Why this Hibernate MySQL Connection is read-only?

前端 未结 2 1884
暗喜
暗喜 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.

提交回复
热议问题