Skip to content

Component deletion with many-to-one properties #2610

Open
@israelaece

Description

@israelaece

I'm using the NH 5.3.5 and I continue dealing with #1755 issue (removing composite-element from <set/> collections), but, in my case, the composite-element has three properties, two of them are many-to-one.

Note that my Description property in Item class is not-null="true". When I set this property to not-null="false" the problem goes away, but in terms of my business domain, this property shouldn't be null.

STEP 1: I added two items in parent entity and save it;
STEP 2: After, I load the entity, clear all items and I insert exactly the same item that I removed. DELETE clause generated is:

DELETE FROM ParentItems WHERE ParentId = @p0 AND Description = @p1 AND CompanyId is null

And we can note that PersonId column (Person property) not appear in the WHERE. Like a said, if I change the Description property to not-null="false", the DELETE is:

DELETE FROM ParentItems WHERE ParentId = @p0 AND Description = @p1 AND PersonId = @p2 AND CompanyId is null

The full reproducable code is here: https://gist.github.com/israelaece/c0d64a807a2223df56411e08c75ce372

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions