vladmihalcea / hypersistence-optimizer

Hypersistence Optimizer allows you to get the most out of JPA and Hibernate. By scanning your application configuration and mappings, Hypersistence Optimizer can tell you what changes you need to do to speed up your data access layer.
https://vladmihalcea.com/hypersistence-optimizer/
Apache License 2.0
306 stars 43 forks source link

TableRowAlreadyManagedEvent is triggered for entities using SINGLE_TABLE inheritance #244

Closed bogdhy closed 2 months ago

bogdhy commented 2 months ago

Hello Vlad,

From what I've understood from the TableRowAlreadyManagedEvent documentation this is triggered when you load two different entities that point to the same database table record.

But in our case, this was reported for entities that point to a different record: image

This is how the records are defined:

image

image

image

Let me know if you need more information.

Best, Bogdan

vladmihalcea commented 2 months ago

I think it's because of the entity inheritance. Could you provide a replicating test case in the test repository?

You can use this test case as a template for your replicating test case.

bogdhy commented 2 months ago

Hello,

Here is the test case but it seems that with Hibernate 6 the TableRowAlreadyManagedEvent is not dispached.

Do you have any guidelines on how to run the test with Hibernate 5.6?

The version on our end is 5.6.15.Final</hibernate.version>

Best, Bogdan

vladmihalcea commented 2 months ago

There are branches for every Hibernate version. For instance, this is the Hibernate 5.6 branch.

But, don't worry, I will use the provided test case as a reference to see if I can replicate it on older Hibernate versions. I'll let you know if I can't replicate it.

vladmihalcea commented 2 months ago

@bogdhy I managed to replicate it and will provide a fix for it in the next version that will be released soon.

bogdhy commented 2 months ago

@vladmihalcea glad I could help.

I'm looking forward for the new release.

All the best, Bogdan

vladmihalcea commented 2 months ago

Fixed.