Hi, new to the forum so pls let me know if the format/question makes sense.
I’m working on a spring boot application that runs a relatively small H2 database underneath. The application interacts with the DB through JPA Since moving to Spring boot 3 (from 2.7) and upgrading hibernate the insert performance (save method in a JPA repo) slowed down dramatically. Well, JPA save is not really an insert but…
After a bit of investigation the entities inserted - that use @EmbeddedId - run a select before the insert, as expected (usual check for merge). The problem is - the select generated looks like:
select p1_0.x,p1_0.y from mytable p1_0 where (p1_0.x,p1_0.y) in((‘mypieceofId1’, 1677042000000))
H2 does not pick up the index, and runs a table scan. It would work if it was
select p1_0.x,p1_0.y from mytable p1_0 where p1_0.x = ‘mypieceofId1’ and p1_0.y= 1677042000000
I would appreciate if somebody could shed some light on this behavior, if it’s a recent change and most of all if there is a way to get hibernate to generate a more efficient query.
For certain entities I can simply make them @Persistable and override isNew but for others it would require a good amount of work.
Any help/advice wcome!