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
-~----------~----~----~----~------~----~------~--~---