Missing 'equals', 'hashCode' and 'toString' in data class entity
Reports data classes used as JPA entities without overridden equals, hashCode and toString.
Default data class implementations of equals, hashCode and toString are not recommended for JPA entities. They do not consider possible proxies and might break lazy initialization of entity attributes. This can lead to issues with correctness and performance, such as duplicated entries in hash-based collections and preemptive eager fetch from the database.
Example:
After applying the quickfix:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
DataClassEntityWithoutOverridesInspection- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection ID: DataClassEntityWithoutOverridesInspection
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |