Team.java
@Entity
@Table(name = "team")
public class Team {
@Id
@Column(name = "team_id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@NotNull
@NotEmpty
@Size(max = 30)
private String leadName;
@NotNull
@NotEmpty
@Email(message = "email must be valid")
private String leadEmail;
@NotNull
@NotEmpty
@Size(max = 30)
private String teamName;
@ManyToOne
@JoinColumn(name = "city_id")
private City city;
@OneToMany( cascade = CascadeType.ALL)
@JoinColumn(name = "team_id")
private List<Idea> ideas;
@NotNull
@NotEmpty
private String organization;
...
}
这是JAVA Hibernate类(Spring Boot),并且存在TeamRepository类。插入之前,我想检查JPA信息库(TeamRepository)中是否存在相同的条目。休眠注释怎么办?可能吗?