-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected dirty checking behavior on collections of POJOs mapped with JsonBinaryType #138
Comments
Thanks for the analysis. It would be great if you proposed a Pull Request as well. I'll review it once it's ready. Also, you need to add a replicating test case that proves the issue as well. |
A small project to prove the problem: hibernate_types_138.zip |
I think it's better to fork the project and create a replicating test case from an existing test case. This way, the test can prevent the issue from occurring in future as well. |
This commit proves that everything works as expected. The only case where I found the issue that you are describing is if you are using a Collection of Objects that don't implement equals or hashCode based on the inner properties, so the default |
@vladmihalcea after 4 days of debugging and a lot of logs(including a hot fix) I found that my issue was caused by a similar case.
Is this documented somewhere? Thanks in advance |
@cosminseceleanu I think it's useful to add it to the README.md doc. Send me a Pull Request with the change. Thanks. |
…checking behavior
@vladmihalcea I updated the docs. Please review. Off topic: I think this project is missing a contribution guide 😃 |
Thanks. I'll review it when I have some time. It would be great if there were a Contribution Guide too. You can supply one if you like. |
another half a day spent on hair-pulling due to this issue.. :) I decided to bump many things at once - my bad. eventually settled down on this problem. Works fine with However, I still can't understand what is the root cause, will have to check further. Right now it seems that all of the following:
And no warnings are given in 2.10.1 version either, I guess because I'll see if I can submit a reproducible test project soon. |
Usually, this is caused by bad Most likely you added |
to clarify - by "entity" we mean JPA Entity, by POJO - the type, that is persisted as JSON column, right ? So, in this case: @Entity
@Table(name = "RA_OUTBOX_RECORDS")
@Getter @Setter @ToString
@TypeDef(
name = "jsonb",
typeClass = JsonBlobType.class
)
public class DocumentOutboxRecord {
///
@Column(name = "PAYLOAD")
@Type(type = "jsonb")
DocumentPayloadV10 payload;
///
and by "implementing equals/hashCode for POJO attributes" we mean that all custom (non-JDK) types, used inside the POJO type, and their attributes in turn, all should have well, if that is correct, then "POJO" and the only custom type used in the POJO definition, they both have And by the way, I have narrowed down the problem starting point: it was in 2.9.3 version of "hibernate-types-52" artifact. So, with 2.9.0/2.9.1/2.9.2 all is fine (just as with 2.5.2, for example), and with 2.9.3. and all subsequent versions - all goes bust.. Version number being the only difference |
yes
yes
It depends on the structure of the
You can track the change log to see what caused the issue. At the moment, I'm very busy with other project and won't have the time to investigate issues or do any development for this framework. But, as soon as I have more time (Jan-March 2022) I'll take a look at your fndings. |
Sure, Vlad, this is not to somehow grab your attention or whatever, just for some other future poor soul who might end up in this issue (and most likely myself!) I'll check the diff, thanks! |
There's this section in the README file that should prevent people from bumping into this issue. Looking forward to checking your analysis. |
(I've posted a big comment but now it seems that the problem was with something else.. I will investigate further) EDIT: I've added a |
I don't know what the |
Description
When reading entities with collections of POJOs such as TestEntity (see Example 1), updates are performed on the database without the objects being changed.
Example 1
Analysis
It appears as if the dirty check on JsonBinaryType properties for collections of POJOs does no longer work as expected.
The problem occurs since [commit-1]. This commit introduces a new dirty checking behavior for JsonBinaryType, when used with collections:
JsonTypeDescriptor
I would not expect the usage of java.lang.Object#equals at this point. In my understanding it creates an inconsistency compared to the dirty checking behavior used for non-collection types.
The recursive field by field comparison before [commit-1] is appropriate in my opinion.
Workaround
Downgrade to the version before [commit-1]: version 2.4.2.
Links
commit-1
The text was updated successfully, but these errors were encountered: