java.lang.Object
springboot.bg.harisauto.user.model.User

@Entity public class User extends Object
User.java - Entity class for storing user information.
Author:
Kristian Popov
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
    Identity-based equality.
    int
    Constant hash, so an instance keeps the same bucket before and after it is persisted.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • User

      public User()
  • Method Details

    • equals

      public boolean equals(Object other)
      Identity-based equality.

      Deriving equality from the fields, as @Data did, is unsafe for an entity: two distinct rows holding the same values compared equal, the hash changed as the instance was mutated, and the comparison reached into the vehicles collection - which now would trigger a lazy load.

      Overrides:
      equals in class Object
      Parameters:
      other - The object to compare with.
      Returns:
      true when both are users with the same, non-null id.
    • hashCode

      public int hashCode()
      Constant hash, so an instance keeps the same bucket before and after it is persisted.
      Overrides:
      hashCode in class Object
      Returns:
      A stable hash code.