BaseEntity
@Entity
@Table(name = "profile")
public class Player {
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@Min(5)
@Max(25)
@Column(name = "name", nullable = false)
private String name;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "rank_id",)
private Rank rank;
}
RankEntity:
@Entity
@Table(name = "rank")
public class Rank {
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@Column(name = "name", nullable = false, updatable = false)
private String name;
@Column(name = "permissions")
@ElementCollection
private Set<String> permissions = new HashSet<>();
}
In Player entity exists column rank. How do I specify a default value for it so that it gets the rank entity when it is initialized?