I continually run into this problem and I am not sure I understand
what is happening
I have a User entity and a Comment entity with the User class having
an ISet of the Comments.
IN the Comment.hbm.xml I have the following mapping
<many-to-one name="User" column="UserID" access="property"
cascade="none" />
In the User.hbm.xml I have
<set name="Comment" lazy="true" table="Comment" cascade="all-delete-
orphan" inverse="true" >
<key column="UserID"/>
<one-to-many class="Comment"/>
</set>
I will normally join the User entity, Comment.User, but I do not want
eager fetching by default.
This used to work and now it gives me an error. "Could not initialize
proxy - no Session" I assume that it has to do with my mapping but I
am not sure.
using (ISession session =
NHibernateSessionManager.Instance.GetSession())
{
IQuery query = session.CreateQuery("from Comment
comment" +
" left join fetch commentUser" +
" order by comment.CommentID desc");
query.SetFirstResult(0);
query.SetMaxResults(25);
IList<Comment> iComments = query.List<Comment>();
List<Comment> comments = new List<Comment>(iComments);
return comments;
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---