I'm using Roo to perform database reverse engineering on
a database with many foreign key constraints.
I'm having trouble fetching an object from the database in
a controller.
When I first started trying to do this, I'd get an error like this:
I did a little reading and realized OpenEntityManagerInViewFilterCode:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.HibernateException: collection is not associated with any session
was intended just for this situation, so I added this to my web.xml:
So, now when it tries to fetch this object, it churns for about 20 minutesCode:<filter> <filter-name>OpenEntityManagerInViewFilter</filter-name> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>OpenEntityManagerInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
and finally throws a stack overflow exception. I can see in the log file it's
doing one database query after another, apparently loading the whole
database as it follows all the foreign key constraints.
I'd like to tell it to use lazy loading globally in persistence.xml, but I can't
figure out how to do that. I'd prefer not to go into all the entity classes and
annotate each method with
as all of this work would be undone if I ever had to run Roo DBRE again.Code:@Basic(fetch = FetchType.LAZY)
Is there a way to tell Roo to do this?
Or if I'm totally barking up the wrong tree, please clue me.
Thanks in advance.


Reply With Quote