Powiedzmy, ze mam nastepujace encje:
@Entity
public class ArticleCategoryEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@NotBlank
@Size(min = 1, max = 80)
@Column(unique = true)
private String name; // Pole unikalne
@Size(min = 1, max = 256)
private String description;
@OneToMany(mappedBy = "category")
private Set<ArticleEntity> articles = new HashSet<>();
}
@Entity
public class ArticleEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@NotBlank
@Size(min = 1, max = 4096)
private String text;
@NotNull
private LocalDate published;
@ManyToOne
private ArticleCategoryEntity category;
@OneToMany(mappedBy = "article")
private Set<CommentEntity> comments = new HashSet<>();
}
@Entity
public class CommentEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@NotBlank
@Size(min = 1, max = 512)
private String text;
@NotNull
private LocalDate date;
@ManyToOne
private ArticleEntity article;
}
Jak waszym zdaniem powinny wygladac metody equals i hashCode dla powyższych przypadkow?