2nd level cache is an advanced concept that takes a fair amount of configuration to prevent users from abusing it. Oren has some great material on it. http://ayende.com/Blog/archive/2009/04/24/nhibernate-2nd-level-cache.aspx http://ayende.com/Blog/archive/2009/06/04/nhibernate-ndash-beware-of-inadvisably-applied-caching-strategies.aspx http://ayende.com/Blog/archive/2008/01/24/NHibernate-and-the-second-level-cache-tips.aspx
as an FYI you can rewrite your query string this way. IQuery query = session.CreateQuery(@" from Comment comment left join comment.User order by comment.CommentID desc"); On Jun 9, 1:48 pm, sed <[email protected]> wrote: > I am new to NHibernate and I am trying to find the best way to achieve > a particular query. I would like to use the secondary cache because > this query is is executed several times a second retrieving mostly the > same objects. Therefore I am using IQuery.Enumerable<T> to retrieve > the results. > > There is data in two entities(Comment and User) that I will always > need to retrieve. For example > > I would have a Comment Class with a many-to-one relation to a User > class. In the database I have a Comment table and a User table. > > The comment object would have Comment.User property that contained > the user data that would need to be retrieved for each Comment object > (joined on a UserID column). > > I get some errors and I am not sure this is possible. I have not seen > any documentation relating to my situation. > > My code so far.. > > IQuery query = session.CreateQuery("from Comment comment" + > " left join comment.User" + > " order by comment.CommentID desc"); > query.SetFirstResult(0); > query.SetMaxResults(n); > IEnumerable<Comment> comments = > query.Enumerable<Comment>(); > > If it is possible to use secondary cache in this manner could someone > point me in the right direction? If not what would be the recommended > approach for handling this situation? A big thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
