Hi Fabio
I'm using plain session.Get<Parent>(1), and the child collections is
lazyloaded. And it's happening when I access the child collection.
Parent map:
public class ParentMap : ClassMap<Parent>
{
public ParentMap()
{
Id(x => x.Id)
.GeneratedBy.Identity()
;
HasMany<Child>(x => x.Child)
.Access.PascalCaseField(Prefix.Underscore)
.Inverse()
.AsSet()
.LazyLoad()
.Cascade.All()
;
}
}
Child map:
public class ChildMap : ClassMap<Child>
{
public ChildMap()
{
Id(x => x.Id)
.GeneratedBy.Identity()
;
Map(x => x.Date)
.Not.Nullable()
;
References<Parent>(Reveal.Property<Child>("Parent"))
.Cascade.None()
;
}
}
Ken
On Apr 7, 9:38 pm, Fabio Maulo <[email protected]> wrote:
> The mapping is generated and is a little bit difficult to read...
> btw even the SQL is generated by NH and what is important is the original
> query.
> Which is the query ? (HQL, Criteria, QueryOver, Linq)
>
> 2010/4/7 Kenneth <[email protected]>
>
>
>
> > Taken from NHProf:
> > SELECT cancellati0_.Subscription_id as Subscrip3_1_,
> > cancellati0_.Id as Id1_,
> > cancellati0_.Id as Id5_0_,
> > cancellati0_.Date as Date5_0_,
> > cancellati0_.Subscription_id as Subscrip3_5_0_
> > FROM [CancellationDate] cancellati0_
> > WHERE cancellati0_.Subscription_id = 1 /* @p0 */
>
> > Maps:
> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> > access="property" auto-import="true" default-cascade="none" default-
> > lazy="true">
> > <class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
> > name="SubscriptionWithData.CancellationDate, SubscriptionWithData,
> > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > table="`CancellationDate`">
> > <id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > <column name="Id" />
> > <generator class="identity" />
> > </id>
> > <property name="Date" type="System.DateTime, mscorlib,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > <column name="Date" not-null="true" />
> > </property>
> > <many-to-one cascade="none"
> > class="SubscriptionWithData.Subscription, SubscriptionWithData,
> > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > name="Subscription">
> > <column name="Subscription_id" />
> > </many-to-one>
> > </class>
> > </hibernate-mapping>
>
> > Is there a reason why NH selects the same column multiple twice?
>
> > Ken
>
> > --
> > 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.
>
> --
> Fabio Maulo
--
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.