Results 1 to 4 of 4

Thread: Configuring lazy fetching for DBRE application

  1. #1

    Default 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:

    Code:
    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:

    Code:
        <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>
    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

    Code:
    @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. #2

    Default

    Anyone?????

  3. #3
    Join Date
    Jun 2012
    Posts
    2

    Default

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

  4. #4
    Join Date
    Nov 2008
    Posts
    25

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •