These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Nhibernate query caching
PostPosted: Mon Aug 24, 2009 5:26 am 
Newbie

Joined: Thu Aug 13, 2009 3:52 pm
Posts: 4
Hi,

I have a function that returns me an Question entity. This Question entity has also an List of Answer entities. The query is cached. But when I try to get the related answers only the Question entity will be read from the cache and not the answers.

How can I also cache the releated answers?

Code:
Dim nextQuestion As Objects.Question = getNextQuestion()
nextQuestion.Answer

Private Function getNextQuestion() As Objects.Question
        Dim session As ISession = SessionHelper.CurrentSession()
        Dim str As New StringBuilder()
        Dim query As IQuery

        str.Append("FROM Question as question WHERE NOT EXISTS( ")
        str.Append("FROM UserAnswer as userAnswer ")
        str.Append("INNER JOIN userAnswer.Answer as answer ")
        str.Append("INNER JOIN answer.Question as question2 ")
        str.Append("WHERE question2.Id = question.Id and userAnswer.UserGuid = :userGuid) ")
        str.Append("ORDER BY question.Ordernr")

        query = session.CreateQuery(str.ToString())

        query.SetString("userGuid", UserGuid.ToString())

        Return query.List(Of Objects.Question)().FirstOrDefault()
    End Function


Thx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.