I pass the Id of the Object to Detailspage and use onActivate() to query for
the object I want to show in detail. 

My Details Page:

public class GeneDetails {
    ...
    @Persist
    private Gene gene;

    @Inject
    private GeneDAO geneDAO;  
    ...
    Object onActivate(Long id){
        if(userExists){
           gene = geneDAO.getGeneById(id);
           return GeneDetails.class;
        }
        else
           return Index.class;
    }
    ...
}

My Gene.class

public class Gene {
    ...
    private Set<Reagent> reagents;
    ...
}

The exception is thrown when i call:

<t:if t:test="gene.reagents.isEmpty()">

If I understand this right, the session is closed directly after the query
was done and before the page is rendered. Do I have to query again for my
collection when I want to access it or is there any way to keep the session
open until the page-rendering has finished?

Thanks

...

Davor Hrg wrote:
> 
> you should post some code,
> 
> but the most likely scenario is that you are persisting
> Entities in your page
> 
> this is not good because every request has a different session,
> and the session that loaded the collection  was closed in a previous
> request,
> 
> you should remember your search parameters instead holding on to the
> collection,
> 
> If you are trying to optimize performance by caching results
> please don't, that is not the way hibernate supports it.
> you should always query again and let hibernate handle performance,
> to cache query results you'll need to get to know hibernate more
> and it's caching configuration (second-level cache, query cache ...).
> 
> 
> Davor Hrg
> 
> On Tue, Aug 26, 2008 at 10:35 AM, moritzgilsdorf
> <[EMAIL PROTECTED]>wrote:
> 
>>
>> Hi,
>>
>> I have a Problem with lazy loading. In my App I query a Database using
>> Hibernate. The workflow is the following:
>>
>> Searchpage           ->  Resultspage     ->  Detailspage
>> ------------------------------------------------------------------------
>> search by keyword ->  Results in Grid ->  Details of picked result
>>
>> The queried Objects contain a collection that should be presented on the
>> Detailspage and loaded there lazily. When a hit in the result grid is
>> clicked, I pass the Id of the entry using the page activation context to
>> Detailspage (I want the Details to be bookmarkable). But when accessing
>> the
>> collection on the Detailspage, the  LazyInitializationException is
>> thrown.
>> For Database-access I use an injected service interface.
>>
>> I believe this is not an unusual scenario so I hope anyone here can give
>> me
>> a hint on how to solve this problem.
>>
>> Thanks, Moritz
>> --
>> View this message in context:
>> http://n2.nabble.com/LazyInitializationException-tp783491p783491.html
>> Sent from the Tapestry Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/LazyInitializationException-tp783491p783576.html
Sent from the Tapestry Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to