Association class & Composite-id

Hi,
is there any chance that VP generate follow code for the relationship depicted on attachment?:

 
    <class name="BigEntity" table="`A`" lazy="false">
        <id name="ID" column="`ID`" type="integer" unsaved-value="0">
            <generator class="native">
            </generator>
        </id>
        <property name="testo" column="`testo`" type="string" length="255"
                  not-null="false" lazy="false"/>

       <!--
      WITHOUT THIS COLLECTION
      <bag name="entities" lazy="true" cascade="save-update,lock"
             inverse="true">
            <key column="`AID`" not-null="false"/>
            <one-to-many
                    class="Entity"/>
        </bag>
        -->
 

I need for a simple reason: bag name contains more than 1000 elements. Hibernate go to sleep every time loads the collection.

Thanks

Maurizio
Class Diagram1.jpg

Hello maurizio316,

The only way to not generate the bag collection is specify the association as non-persistable (under the ORM Association Detail tab in Association Specification dialog). But this will also remove the relationships between BigEntity and LittleEntity in generated ORM code.

As you mention it take lots of time to load the collection, may I know you need to load the entire collection? If you are looking for specific records, I think the criteria class can help a lot.

Best regards,
Rain Wong

Hi Rain,

I need persistent relation Entity->BigEntity, Entity->LittleEntity.

As you mention it take lots of time to load the collection, may I know you need to load the entire collection?

I don’t need to load collection, it’s hibernate need: when I invoke BigEntity.AddLittleEntity(Entity, LittleEntity), hibernate proxy load entire collection.

Thanks

Maurizio

Hello maurizio316,

Actually setting both From and To association end to Extra Lazy will not causing the collection being loaded when adding objects to collection. You can set the association to Extra Lazy inside the ORM Association Detail tab of the Association Specification dialog. If you require any further information, please do not hesitate to contact me again.

Best regards,
Rain Wong

Hi,
Am I wrong or Nhibernate doesn’t support extra lazy association?

At the moment I bypass the “issue” in the following way:

BigEntity <----X Entity <------> LittleEntity

Pls tell me if it isn’t right.

[quote=Rain]Hello maurizio316,

Actually setting both From and To association end to Extra Lazy will not causing the collection being loaded when adding objects to collection. You can set the association to Extra Lazy inside the ORM Association Detail tab of the Association Specification dialog. If you require any further information, please do not hesitate to contact me again.

Best regards,
Rain Wong[/quote]