Domain Description
I am using a combination of
Spring + Hibernate + Tuckey Urlrewrite
In a Spring Framework Web app.
I have a simple data strucutre
Special has 1:Many Image object
I am using the language in the url:
http://site.com/
en/someview
or
http://site.com/
de/someview
and so on
There is also a default url:
http://site.com/
I am using Tucky Urlrewrite to rewrite the urls from
http://site.com/
en/someview
to
http://site.com/someview?lang=en
in order select the correct language for the page
(I am doing this to allow the user to simply change the language in the url and have the site change language accordingly)
I am loading the Special object in the Default controller
I am passing the Special object to the view and loading the Images there.
Problem Description
When hitting http://site.com/
everything works as expected. Looking at the logs for Turkey it is NOT doing any rewrite.
When hitting http://site.com/en/
or http://site.com/de/
i am getting the dreaded
"failed to lazily initialize a collection of role"
I can prove that there is something with Tuckey Urlrewrite because when i enter the "rewritten" urls into the address bar they work and even removing Tuckey Urlrewrite all together.
I have tried the following
- Loading the Images in the controller - did not work
- Using the OpenEntityManagerInViewInterceptor -- did not work
- Using Tuckey's dispatcher REQUEST/FORWARD -- did not work
- Using Tuckey's type="redirect" -- did work but as expected redirected the browser
- Used the OneToMany attribute's fetch=FetchType.EAGER -- worked (but in the long term not desirable)
I am open to all suggestions to remove the use of the FetchType.EAGER.
Some ideas i have are
- Different method of Url rewriting i.e. if it is possiable to set tomcat to handle the rewrite before the DispachFilter
- Different urlrewriter i.e. different product, or internal Spring URL Rewriter
Sites i have read
- Why Doesn't Tuckey UrlRewrite Filter call chain.doFilter after a rule is matched?
- Hibernate lazy initialization exception (most promissing but nothing there worked)
- Hibernate (JPA) how to do an eager query, loading all child objects (finally to give up and use EAGER)
Really would be very thankful for any hints
Adam