Inspectopedia 2026.1 Help

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:

@Entity data class Employee( @Id @GeneratedValue var id: Long? = null, var name: String = "", var department: String = "" )

After applying the quickfix:

@Entity class Employee( @Id @GeneratedValue var id: Long? = null, var name: String = "", var department: String = "" )

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.

Settings or Preferences | Editor | Inspections | JPA | Kotlin

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:

//noinspection DataClassEntityWithoutOverridesInspection

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:

IntelliJ IDEA 2026.1, Qodana for JVM 2026.1,

Last modified: 31 March 2026