Transactions, Connections and Scrollable ResultSets



    I'd like to find out what the problem is in our applicaton currently.


    We have a ScrollableResultSet which allows jasper to build reports containing a large quantity of records.

    Each group has a subquery for which I want to perform another hibernate query however I have the following problems.


    1. in the default way, of say using a pojo seam component with an injected EntityManager, the subquery causes the ScrollableResultSet to close.


    The second call to next() on the scrollableresultset raises an exception indicating this.



    2. If I wrap the main jasper report process in a seam component with an @Transactional(REQUIRED) method then I cannot access hibernate objects after the initial run.


    the second call to next works fine, but the hibernate object within is somehow borked -

       IllegalArgumentException in class:, getter method of property: id





    These problems occur at the same point in the process......


    Start main report process.....

         load first group

            run first subreport

         load second group <-- !! ERROR !!




    How can I run a subquery on the database, whilst another long-running one is active using scroll?



    Many thanks for any insights.