我有多对多的映射表client_platform。我想强制hibernate从Platform表中选择platform_id,而不是在platform table上运行insert。
客户端:
@Id
@Column(
name = "client_id",
columnDefinition = "BINARY(16)"
)
private UUID id;
@Column(name = "client_name")
private String name;
@ManyToMany(
fetch = FetchType.LAZY,
cascade = {CascadeType.ALL}
)
@JoinTable(
name = "client_platforms",
joinColumns = @JoinColumn(
name = "client_id",
updatable = false,
nullable = false
),
inverseJoinColumns = @JoinColumn(
name = "platform_id",
updatable = false,
nullable = false
)
)
private Set<Platform> platforms;
平台:
@ManyToMany(
mappedBy = "platforms",
fetch = FetchType.LAZY,
cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}
)
private Set<Client> clients;
当我插入Client时,它会插入到Platform和client_platform连接表
中如何在插入platform和client_platform表之前更改JPA注释以强制hibernate在平台上执行选择