You don't say what goes wrong when the referrers count becomes large.

As for deleting, yes I'd use a separate Delete HQL statement for the
Referrers before deleting the Page.


Richard

On Jan 14, 3:52 pm, Ramon Smits <[email protected]> wrote:
> Assume this database relation:
>
>    Post [1] <- [0..10000] Referrer
>
> So we have a multitude of posts and a post can have 0 till infinite
> referrers. Below my initial NHibernate mapping. I have left all data
> columns out for easy reading.
>
>   <class name="Page">
>     <id name="Id" type="Guid">
>       <generator class="assigned"/>
>     </id>
>     <bag name="Referrers" inverse="true" cascade="all-delete-orphan">
>       <key column="post_id" not-null="true"/>
>       <one-to-many class="Referrer"/>
>     </bag>
>   </class>
>
>   <class name="Referrer">
>     <id name="Id" type="Guid">
>       <generator class="assigned"/>
>     </id>
>     <many-to-one name="Page" class="Page" column="page_id" not-
> null="true"/>
>   </class>
>
> This works pretty until the referrers count becomes large. Also,
> deleting pages results in seperate delete statements instead of one
> because I do not leave that to the database via cascading deletes.
> Improving deletion performance would mean that I need to enable
> cascading deletes on the database.
>
> So would it be better to just drop the bag from the Page? Then I
> should query for page referrers manually instead via lazy loading and
> have a seperate delete query as well before deleting the page object
> as I still have a foreign key constraint that is active.
>
> Ramon
-- 
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