Hi Nexus,
The Update method call is totally unnecessary, indeed. Thanks for pointing
it out.
About your second comment, if I use Get the entity will be loaded
immediately while the Load method delays the loading until a property of the
root entity (User) is called (in this case, the OwnedBlogs collection).
I heard a few times that it is wise to wrap the list property just like
this:
public class User {
private IList<WebLog> ownedBlogs { get; set; }
public void AddBlog(WebLog webLog) {
this.ownedBlogs.Add(webLog);
}
public IEnumerable<WebLog> OwnedBlogs {
get { return this.ownedBlogs; }
}
}
I'm sure this is a good
thing<http://www.google.com.br/url?sa=t&source=web&cd=1&ved=0CBoQFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLaw_of_Demeter&ei=KTXATPmAFoP-8AahsPDrBA&usg=AFQjCNGEB0daZpegnR5NWGCb312GaiySww&sig2=ECjwRdSjceR7cphikEclsA>,
but I wonder if this has something to do with the problem I mentioned
(necessity of loading the user entity to insert a related WebLog). I know
that in 99% of the situations there is no point in trying to avoid that
extra SELECT but my motivation is to understand better how NHibernate works
internally.
Thanks for your attention!
On Thu, Oct 21, 2010 at 7:52 AM, Nexus <[email protected]> wrote:
> Hi,
>
> Why are you calling session.update(user) in the first example
>
> And its's normal that the user is loaded don't use load use get, the
> only difference between lazy is extra or lazy = true is related to the
> collection of Weblogs
>
> Kind regards
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
--
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.