Composite id with UnsavedValue="any" disallows to delete entity #2725
Replies: 1 comment 6 replies
-
This is by design. When using
This should also have the "side effect" of causing NHibernate to always insert the entities even when they already exist, when doing a Or you should cease working directly on these entities but instead build DML statements. |
Beta Was this translation helpful? Give feedback.
-
We use a table with a composite primary key for many-to-many relationship. The mapping is shown below:
mapping.CompositeId().KeyReference(e => e.POINT).KeyReference(e => e.NODE).UnsavedValue("any");
To prevent unnecessary SELECT sql-commands in SaveOrUpdate we added UnsavedValue("any") option in mapping.
But after that we noticed that entity deletion command does not delete entity any more:
session.Delete(entity);
There is neither exception nor warning. The command is just ignored.
If we remove
UnsavedValue("any")
from mapping thensession.Delete(entity)
works perfectly, but we get big number of excessive selects during saving entities.Is there any way to delete entity with composite id and UnsavedValue=any?
Version of NHibernate is 5.3.8.
Database is Oracle.
Beta Was this translation helpful? Give feedback.
All reactions