Deleting all entities of a given type fails when using a composite primary key and order_updates

Description

We are unable to use the Spring Data JPA’s CrudRepository.deleteAll() method for an entity. We are using the following dependencies:

We originally posted this bug to the Spring Data JPA team however after investigating it they suggested it is a Hibernate bug - .

Entity Model

Our Entity Model consists of the following:

Note that FormVersion entities have a composite primary key consisting of the Form ID and a version number.

Bug

When we create more than one FormVersion entity and try to delete them all by using the CrudRepository.deleteAll()
method, we encounter the following error:

Note that when the entity model is modified to remove the FormInput entity, the bug does not occur. It may be related in some way to the composite primary key on the FormVersion entity being used as a foreign key by the FormInput entity.

Possibly Related Bug

We are aware of an existing bug relating to deleteAll(): I believe this is likely separate to this issue however because the workaround suggested - add getters and setters to all fields - does not apply here as all fields on entities already have getters and setters.

Entity Model

Our entities are as follows:

Test Case

We have created a project on Github reproducing the issue here:

Activity

Show:

Andrea Boriero July 13, 2023 at 4:43 PM

i created the reproducer for this case and tested with your fix for but it seem not working .

 

Can you please give a look at ? Thanks

Philip Lowney July 12, 2023 at 11:47 AM

Thank you @Marco Balladelli for checking into this so quickly. I will build locally once HH-26709 is merged and I will confirm that this is resolved.

Marco Belladelli July 12, 2023 at 8:19 AM
Edited

Hello , the error you’re encountering looks identical to what the user reported in .

I believe my proposed change will fix your issue too. As soon as that’s merged you can try building locally to verify this, or wait for the next release of Hibernate to try it out.

Fixed

Details

Assignee

Reporter

Sprint

Fix versions

Affects versions

Priority

Created July 11, 2023 at 3:28 PM
Updated July 20, 2023 at 6:48 PM
Resolved July 17, 2023 at 9:25 AM