I agree with Fabio. The table needs to be selected anyway. It does not
make sense to only read half the columns from the table, and read the
rest in another query. Usually, the most expensive are db roundtrips
and joins.

I think hival's mapping is what you need.

You need to know what it means to use components. They are no
independent entities and can only be loaded with the parent. You can't
have a query for ProductDetails in your case, only for Products (but
you can filter them by details of course).


On 10 Aug., 15:32, Fabio Maulo <[email protected]> wrote:
> lazy loading for components does not have any sense.
>
> 2009/8/10 Jeffrey Zhao <[email protected]>
>
>
>
>
>
> > But component mapping cannot implement lazy load. Any ways to get both
> > single table one-to-one mapping and lazy load?
>
> > Jeffrey Zhao
> > Blog:http://www.cnblogs.com/JeffreyZhao/
> > Twitter:http://twitter.com/jeffz_cn
>
> > --------------------------------------------------
> > From: "hival" <[email protected]>
> > Sent: Monday, August 10, 2009 4:36 PM
> > To: "nhusers" <[email protected]>
> > Subject: [nhusers] Re: Mapping one-to-one relationship in a single table
>
> > > To use associations your table should contain a foreign key. In your
> > > current table definition you should use component, and the mapping
> > > like this:
>
> > > <class name="Product" table="Product">
> > >        <id name="ProductID" column="ProductID">
> > >           <generator class="hilo"/>
> > >        </id>
> > >        <property name="Name"/>
> > >        <property name="Price"/>
>
> > >        <component name="ProductDetail" class="ProductDetail">
> > >          <parent name="Product" />
> > >          <property name="CreateTime"/>
> > >           <property name="LastUpdated"/>
> > >        </component>
> > >    </class>
>
> > > Remove ProductID property from ProductDetail class
> > > In my opinion <generator class="hilo"/> and [ProductID] [int] IDENTITY
> > > (1,1) NOT NULL is somewhat inconsistent.
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to