Tuesday, June 1, 2010

Battle for the right to write (to my own DB)

I wanna shoot myself. I've been struggling trying to fix a "org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)". I know that I'm a total newbie with Spring and Hibernate (and not really experienced on the inner workings of transaction management) but this is evil if you really don't understand how Spring works.

I don't think the Spring Framework documentation emphasizes it enough: "The most important concepts to grasp with regard to the Spring Framework's declarative transaction support are that this support is enabled via AOP proxies" (Spring's Declarative Transaction Management documentation). I know, I know! It's all my fault but even when I read those lines it really didn't "click": I thought that I was having issues because I've decided to use the OpenSessionInView pattern and believed that I needed to add transaction management to my newest Manager class. So, I've spent more than a day trying to figuring out how to fix this issue when the functionality was there all along. The deal was that my manager wasn't being proxied because it was defined as an inner bean (which can be a good practice in some cases but totally not when you want your bean to be proxied [Spring Best Practices]) :|

No comments:

Post a Comment