Added a hint in the documention for using custom java types with a JSON mapping
We lately run into a problem at my company when using @JdbcTypeCode(SqlTypes.JSON) on a custom java type that triggered many unnecessary update statements. The cause of the problem was that we missed to override the equals-method, in consequence, the dirty-checking mechanism didn't work as expected anymore and all of the managed entities get updated even if nothing has changed.
I found that other users faced the same or a similar problem, e.g.
- https://discourse.hibernate.org/t/extra-update-during-insert-of-entity-with-jsonfield-jdbctypecode-sqltypes-json-property/11908
- https://hibernate.atlassian.net/browse/HHH-17660
Hence, I think it's worth to add a small hint in the documentation.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion. For more information on licensing, please check here.
Thanks for your pull request!
This pull request does not follow the contribution rules. Could you have a look?
❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
↳ Offending commits: [d653a968cb5c3f9b7e0c6e63aaf9b7f09cf0af72]
› This message was automatically generated.
FWIW, we have HHH-17709 which would potentially solve this problem, although it would be a bit inefficient. Generally, I'd say @Embeddable is recommended, as that allows Hibernate ORM to peek into the objects and figure this all out more efficiently.