I have the following class:
The join table ec_resource_pool_resource and the audit table ec_resource_pool_resource_aud both have case-insensitive collation order.
I create a resource pool whose m_resourceNames with some id which contains the entry 'foo', which produces a row in ec_resource_pool_resource with that id and resource_name = 'foo'
I then do:
resourcePool.add("FOO"); // Differs from the previous value only by case
Once this is committed, I find I have TWO rows in ec_resource_pool_resource with the same id one with resource_name = 'FOO' (as expected) but the original one with resource_name = 'foo' – which should have been deleted, but was not.
(NOTE – If you have auditing turned on, you won't be able to get this far, due to a constraint violation due to HHH-12435.)
If I make further changes only by case (e.g. to the resource 'Foo'), then I get even more duplicated rows in ec_resource_pool_resource.
This problem does NOT occur if I put a flush between the delete and the add.
This problem has existed at least since Hibernate 4.3.x.
I haven't yet turned this into a test case – hopefully I'll be able to do so fairly soon.