I don't understand the relation..A has a One-To-Many to B (OK)

B has a ONE-TO-ONE with A ?
What is this?

2008/9/29 Luis Abreu <[EMAIL PROTECTED]>

>
> Hello guys.
>
> question regarding NH 2.0 behaviour:
>
> I've got an entity with a collection of other entities. It looks like
> this (just some pseudo-code that reproduces the scenario):
>
> class A{ public ISet<B> Bs{get;set;} }
> class B{ public A{ get; set; } }
>
> and then the xml looks like this:
>
> a.hbm.xml
> <hibernate-mapping
>  xmlns="urn:nhibernate-mapping-2.2"
>  assembly="SRA.Core.Entidades"
>  namespace="SRA.Core.Entidades"
>  schema="dbo">
>  <class name="A" table="A" lazy="false">
>  ...
>  <set name="Bs" lazy="false" cascade="all-delete-orphan" inverse="true">
>      <key column="IdB" on-delete="cascade" />
>      <one-to-many class="B"/>
>    </set>
> </hibernate-mapping>
>
>
> b.hbm.xml
>
> <hibernate-mapping
>  xmlns="urn:nhibernate-mapping-2.2"
>  assembly="SRA.Core.Entidades"
>  namespace="SRA.Core.Entidades"
>  schema="dbo">
>  <class name="B" table="B" lazy="false">
>  ...
>  <one-to-one class="A" name="A" />
> </hibernate-mapping>
>
>
> As you can see, A is the root aggregate and I won't to delete A. So I
> tried calling session.Delete(a). The problem: I end up getting an ado
> net exception regarding the foreign key between tables A and B. Ok,
> looking at the SQL, it seems like NH will only issue a delete over
> table A, but I was expecting that the cascade all would also issue a
> delete over B (which should be issued before A's delete).
>
> Shouldn't the delete over A be responsible for deleting items from B
> associated with A?
> --
> Regards,
> Luis Abreu
>
> >
>


-- 
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