我找到了this问题和this博客文章。我不确定这是否相关(一些已弃用的代码)并且可能有一种新的更好的方法来做到这一点。
有没有办法为每个查询添加条件?
我们目前的解决方案是用Generator向每个表添加以下内容,开发人员必须手动应用这些方法。最好将此组织过滤器自动应用于(几乎)每个查询。
public org.jooq.Condition filterNotDeleted() {
return this.DELETED.eq(false);
}
public org.jooq.Condition filterOrganizationId(Long organizationId) {
return this.ORGANIZATION_ID.eq(organizationId);
}
public org.jooq.Condition filterOrganizationIdAndNotDeleted(Long organizationId) {
return this.DELETED.eq(false).and(this.ORGANIZATION_ID.eq(organizationId));
}
您的链接仍然相关,尽管现在有新选项而不是使用
VisitListener
,您也可以使用新的实验性Replacer
API 转换查询。
未来的 jOOQ(从 jOOQ 3.18 开始还没有)很可能会支持更多的行级安全性和开箱即用的多租户用例,请参阅#2682。