@Id @GeneratedValue private Long id; private String uuid = UUID.randomUUID().toString(); public int hashCode() { return Objects.hash(uuid); } public boolean equals(Object that) { return this == that || that instanceof BaseEntity && Objects.equals(uuid, ((BaseEntity) that).uuid); }