Tip: you'll need to save your News entity prior to calling CreateContent(), or else you'll not get the correct Id. I usually throw an exception in case I try to call CreateContent() and the Id == 0.
I'm sure there's a more elegant way out there, though... Fábio David Batista [email protected] http://nerd-o-matic.blogspot.com 2009/11/5 Fábio Batista <[email protected]>: > Here is what I usually do: > > http://dblendea.pastebin.com/f2c192a48 > > There's a little more code, but it's simple enough and makes you feel > in control. > > Fábio David Batista > [email protected] > http://nerd-o-matic.blogspot.com > > > > On Thu, Nov 5, 2009 at 4:16 PM, Ricardo Lopes <[email protected]> wrote: >> http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html#performance-fetching-lazyproperties >> The NHibernate 2.1 is comparable to Hibernate 3.2.6 so it should works, I >> just don't know how. >> I doubt there is support for this using ActiveRecord, the alternative is to >> use a projection in HQL or using a criteria. >> Hope that helps. >> 2009/11/5 bdaniel7 <[email protected]> >>> >>> I will ask there too, but I'm using AR to load the objects. >>> >>> On Nov 5, 6:07 pm, Mauricio Scheffer <[email protected]> >>> wrote: >>> > Try asking on nhusers:http://groups.google.com/group/nhusers >>> > >>> > On Nov 5, 1:01 pm, bdaniel7 <[email protected]> wrote: >>> > >>> > > still nobody? >>> > > is my question really that dumb? or that complex? >>> > >>> > > On Oct 21, 9:09 pm, bdaniel7 <[email protected]> wrote: >>> > >>> > > > Anybody...? >>> > >>> > > > On Oct 21, 10:10 am, bdaniel7 <[email protected]> wrote: >>> > >>> > > > > Hello, >>> > >>> > > > > I have this situation:http://dblendea.pastebin.com/f52096576 >>> > >>> > > > > News has some properties and also Content, which is quite large >>> > > > > and I >>> > > > > want it loaded lazily. >>> > > > > I tried to use the example provided by Gabriel Schenker >>> > > > > here:http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/11/17/lazy... >>> > >>> > > > > The hbm-s generated look like his, so I'm assuming I've made it >>> > > > > correctly. >>> > >>> > > > > But the test shows 3 statements instead of one. >>> > > > > Title is notlazy, but Content is. >>> > >>> > > > > 1. SELECT top 2 this_.Id as Id5_0_, this_.Title as Title5_0_, >>> > > > > this_.Content as Content5_0_ FROM News this_ WHERE this_.Title >>> > > > > like >>> > > > > @p0;@p0 = '%Error in NHibernate config!%' >>> > > > > 2. SELECT newsconten0_.Id as Id4_0_, newsconten0_.Text as Text4_0_ >>> > > > > FROM NewsContents newsconten0_ WHERE newsconten0_....@p0;@p0 = 1 >>> > > > > 3. SELECT news0_.Id as Id5_0_, news0_.Title as Title5_0_, >>> > > > > news0_.Content as Content5_0_ FROM News news0_ WHERE >>> > > > > news0_.conte...@p0;@p0 = 1 >>> > >>> > > > > Did I do something wrong or is it another way of loading a >>> > > > > property >>> > > > > lazily? >>> > >>> > > > > Thanks, >>> > > > > Dan >>> >> >> >> >> -- >> >> Ricardo Lopes >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
