JPA @JoinTable with extra join conditions

泄露秘密 提交于 2019-11-28 23:49:43

You can use @WhereJoinTable annotation. It applies to the association table

@OneToMany
@JoinTable(
  name="Contract_Party", 
  joinColumns = {@JoinColumn(name="party_id",referencedColumnName="party_id")},
  inverseJoinColumns = {@JoinColumn(name="contract_id", referencedColumnName="contract_id")}
}
@WhereJoinTable  ( "ROLE = 'SIGNER' ")
private List<Contract> contracts;

You must use:

@WhereJoinTable(clause = "ROLE ='SIGNER'")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!