H5->H6: remove/insert collection entriy's property after flushing

Hello.

Problem after upgrade Spring Boot to 3 version (hibernate became 6.2.0.CR3).
At first i thought it was spring and wrote to them:

Problem with @Embeddable/@ElementCollection (@CollectionTable) on spring boot 3. · Issue #2849 · spring-projects/spring-data-jpa · GitHub

but it turned out that is is due to hibernate.

I started to understand in code. It turned out that when executing “transaction.flush();” eventually we will get to the method in hibernate:
Collections.processReachableCollection
where the following parameters are passed:

collection = {PersistentSet@22794}  size = 1
 0 = {RevisionInfo$ObjectChanged@22884} 
  objectType = "TYPE"
  objectUuid = {UUID@22886} "0e564c51-1636-41f8-a92e-cea01e3d8635"
type = {SetType@21870} "org.hibernate.type.SetType(com.producer.repository.model.RevisionInfo.objectsChanged)"
 role = "com.producer.repository.model.RevisionInfo.objectsChanged"
 foreignKeyPropertyName = "_com_rogii_producer_repository_model_RevisionInfo_objectsChanged"
 persister = {BasicCollectionPersister@22785} "BasicCollectionPersister(com.producer.repository.model.RevisionInfo.objectsChanged)"
entity = {RevisionInfo@22786} 
 revision = {Long@21850} 1
 userId = {Long@21873} 10
 projectUuid = {UUID@22806} "f8367f36-f25c-47f3-bc8d-9c9e85db7631"
 objectsChanged = {PersistentSet@22794}  size = 1

This method has a line:
ce.setCurrentKey( type.getKeyOfOwner( entity, session ) );
Which just in my case gives a different option for hibernate V5 and V6:

V5:
currentKey = {RevisionInfo@22786} 
 revision = {Long@21850} 1
 userId = {Long@21873} 10
 projectUuid = {UUID@22806} "f8367f36-f25c-47f3-bc8d-9c9e85db7631"
 objectsChanged = {PersistentSet@22794}  size = 1
V6:
currentKey = {RevisionInfo$HibernateProxy$z5EmDG9Q@23989} "com.producer.repository.model.RevisionInfo@15365e59"
 $$_hibernate_interceptor = {ByteBuddyInterceptor@24140} 
 revision = null
 userId = null
 projectUuid = null
 objectsChanged = null

And further in the method:
Collections.prepareCollectionForUpdate
defined:
keyChanged (which just compares entry.getLoadedKey(), entry.getCurrentKey() - and for V6 they turn out to be different)
and ownerChanged becomes = true
and entry.setDoremove( true );
and in ActionQueue.executeActions(), because Doremove == true and happend “delete/insert” of RevisionObject records.

I would like to know if it is possible to control it and cancel the “delete/insert” behavior, because in my project users do not have the rights to delete in this table and errors occur.
Thank you.

Please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.