I have three classes:
Login
Role
LoginsInRoles
Login is one-many to LoginsInRoles and Role is one-many to
LoginsInRoles. This is not a traditional many-many relationship
because LoginsInRoles has to be a first class entity because it has
additional properties that are unique to it.
I have set the cascade to delete for login and role relationships.
Yet, when I try to delete a Login, Sql Server will disallow it because
of the related child entities that are not deleted. It seems that
NHibernate will not delete the child entities even with cascade delete
setup. This architecture has worked fine for me when setting up simple
one-to-many relationships but I suspect there is something about my
mapping that is preventing it with the more complex relationship.
Any suggestions about what I am doing wrong?
The related mappings:
Login Entity:
<bag cascade="delete-orphan" name="LoginsInRoles" mutable="true">
<key>
<column name="Login_id" not-null="true" />
</key>
<one-to-many
class="LeafAndBeanSoftware.Domain.Infrastructure.LoginsInRoles,
LeafAndBeanSoftware.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" />
</bag>
Role Entity
<bag cascade="delete" name="LoginsInRoles" mutable="true">
<key>
<column name="Role_id" />
</key>
<one-to-many
class="LeafAndBeanSoftware.Domain.Infrastructure.LoginsInRoles,
LeafAndBeanSoftware.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" />
</bag>
LoginsToRoles Entity
<many-to-one class="LeafAndBeanSoftware.Domain.Infrastructure.Login,
LeafAndBeanSoftware.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" name="Login" update="false">
<column name="Login_id" />
</many-to-one>
<many-to-one
class="LeafAndBeanSoftware.Domain.Infrastructure.Role,
LeafAndBeanSoftware.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" name="Role" update="false">
<column name="Role_id" />
</many-to-one>
<many-to-one
class="LeafAndBeanSoftware.Domain.Infrastructure.Account,
LeafAndBeanSoftware.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" name="Account" update="false">
<column name="Account_id" />
</many-to-one>
--
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.