It's very weird. That's my mapping, can anyone find the difference?
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHTest"
namespace="NHTest">
<class name="User" table="`User`">
<id name="UserID" type="Int32" column="UserID">
<generator class="identity" />
</id>
<one-to-one name="Detail" class="UserDetail" constrained="true"
cascade="save-update" />
<property name="Name" type="String" />
</class>
<class name="UserDetail" table="`UserDetail`" lazy="true">
<id name="UserID" type="Int32" column="UserID">
<generator class="foreign">
<param name="property">User</param>
</generator>
</id>
<one-to-one constrained="true" name="User" class="User" />
<property name="Age" type="Int32" />
</class>
</hibernate-mapping>
But the SQL is still:
SELECT
this_.UserID as UserID0_1_,
this_.Name as Name0_1_,
userdetail2_.UserID as UserID1_0_,
userdetail2_.Age as Age1_0_
FROM
[User] this_
inner join
[UserDetail] userdetail2_
on this_.UserID=userdetail2_.UserID
WHERE
this_.UserID = @p0;
@p0 = 1
I'm also using NH 2.1.0.
Blog: http://www.cnblogs.com/JeffreyZhao/
Twitter: http://twitter.com/jeffz_cn
--------------------------------------------------
From: "hival" <[email protected]>
Sent: Saturday, August 15, 2009 11:46 PM
To: "nhusers" <[email protected]>
Subject: [nhusers] Re: Lazy load of one-to-one association
>
> Hmm...
> Here is my mapping and SQL (NH2.1.0)
>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> assembly="NHTest" namespace="NHTest" auto-import="true">
>
> <class name="Parent" table="parent">
> <id name="Id" column="p_id">
> <generator class="native" />
> </id>
>
> <property name="FieldA" column="p_field_a" />
> <one-to-one name="Child" class="Child" cascade="save-update"
> constrained="true"/>
> </class>
>
> <class name="Child" table="child" lazy="true">
> <id name="Id" column="c_id">
> <generator class="foreign">
> <param name="property">Parent</param>
> </generator>
> </id>
>
> <property name="FieldA" column="c_field_a" />
> <one-to-one name="Parent" class="Parent" constrained="true" />
> </class>
> </hibernate-mapping>
>
> NHibernate:
> /* load NHTest.Parent */ SELECT
> parent0_.p_id as p1_0_0_,
> parent0_.p_field_a as p2_0_0_
> FROM
> parent parent0_
> WHERE
> parent0_.p_...@p0;
> @p0 = 1
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---