Skip to content

Orphans not removed if they have been created in the current session #11666

Description

@ahus1

Describe the bug

When working on #11230 and the associated PR #11328 I've discovered that Hibernate didn't remove orphan childs as expected in some cases.

This lead to Hibernate issue https://hibernate.atlassian.net/browse/HHH-15230 and a workaround of a modified Auto-Flush listener https://github.com/keycloak/keycloak/blob/main/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/hibernate/listeners/JpaAutoFlushListener.java#L82-L84

This issue tracks the upstream issue to remove the workaround once a fix is available.

Version

999-SNAPSHOT

Expected behavior

No custom auto-flush listener should be necessary.

Actual behavior

Custom auto-flush listener necessary as a workaround.

How to Reproduce?

See test case that triggered this was OIDCClientRegistrationTest.testClientWithScope as it was writing client properties multiple times in a session. This behavior might change in future setup; it is simpler to reproduce in the test case linked in the Hibernate issue.

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area/storageIndicates an issue that touches storage (change in data layout or data manipulation)kind/bugCategorizes a PR related to a bugpriority/importantMust be worked on very soonstatus/holdPR should not be merged. On hold for later.team/core-iamteam/core-shared

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions