I have a REST-service exposed through Spring-MVC. I have a particular method which is correctly mapped and called through a HTTP-call. My Spring application contains the HibernateTransactionManager and transactions are configured through @Transactional-annotations. I annotated the method like this:

Whenever I call the HTTP-method I a org.hibernate.LazyInitializationException from my org.springframework.http.converter.json.MappingJacksonHttpMessageConverter which is bound in my application context. Is the @Transactional annotation valid for the MessageConverter as well?

2 Answers
2

Your converter class is obviously reading a field that's configured to be collected lazily in your Hibernate configuration.

Two possible solutions:

Expand your transactional method to include the converter method.

Edit your Hibernate configuration to eagerly fetch the field that's responsible of the LazyInitializationException. (This field can for example be a part of a relationship between two tables in the database.)

I already fixed my problem by doing what was your first proposal. Actually the problem was that another tool that I used for mapping objects, copyed persistbags instead of the real collections...
– KarlMay 11 '10 at 17:33

1

Iam facing the same problem here,Please, how did you that? how did you expand your transactional method?
– storm_busterNov 23 '10 at 4:00