Announcement Announcement Module
No announcement yet.
Configuring lazy fetching for DBRE application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring lazy fetching for DBRE application

    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:

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.HibernateException: collection is not associated with any session
    I did a little reading and realized OpenEntityManagerInViewFilter
    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 minutes
    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

    @Basic(fetch = FetchType.LAZY)
    as all of this work would be undone if I ever had to run Roo DBRE again.

    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.

  • #2


    • #3
      have you solved it?? i've got the same problem =/


      • #4
        You can refactor from the DbManaged aspect into your java file and roo will leave it alone, however any related database changes will have to be reflected manually. An additional problem in editing the generated DbManaged aspect is that roo even without a new reverse engineering will detect the aspect file changed and update it to match the dbre.xml file generated on the last database reverse engineering.

        I'm not sure how to do it globally perhaps update roo with an option and get the roo team to accept it. for updating persistence.xml to do it globally seems is not a roo, perhaps not even a spring, question.