Hello,
I've read a lot on the Internet but I can't find a solution for my
problem :(
Example:
public class Foo
{
public IList<Bar> Bars { get; set; }
}
public class Bar
{
public Foo Foo { get; set; }
}
So it's a classical many-to-one mapping.
The mapping:
Foo:
...
<bag name="Bars" inverse="true" cascade="none" lazy="true">
<key column="ID_FOO" />
<one-to-many class="Bar"/>
</bag>
...
Bar:
...
<many-to-one fetch="select" index="IDX_BAR_FOO" name="Foo" class="Foo"
column="ID_FOO" cascade="none" not-null="true" foreign-
key="FK_BAR_FOO" />
...
I use Session per Request pattern. So I do only have detached entities
in my code.
Now if I load a Foo with some Bars from the Database, the tree may
look like this:
Foo1
|->Bar1
|->Bar2
|->Bar3
Now I remove one Bar from Foo1:
Foo1.Bars.Remoe(Bar1);
Bar1.Foo = null;
The problem is that I can't do
session.Delete(Bar1);
It always tells me that Foo can't be NULL. That's OK. But how do I
tell NHibernate to delete the whole row? If the entities would not be
detached I could use delete-orphan on the collection, but since the
childs are detached this doesn't work neither :(
I hope anybody has an idea how to solve this.
Thanks in advance!!!!
Greetings
--
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.