@MappedSuperclass
interface TenantAware {
val tenantId: Int
}
@Component
class TenantFilter : KAssociationIntegrityAssuranceFilter<TenantAware> {
override fun filter(args: KFilterArgs<TenantAware>) {
1?.let {
args.apply {
where(table.tenantId.eq(it))
}
}
}
}
@Entity
@Table(name = "book")
interface Book : TenantAware {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
val id: Int
val name: String
@ManyToOne
@JoinColumn(name = "author_id")
val author: Author
}
@Entity
@Table(name = "author")
interface Author : TenantAware {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
val id: Int
val name: String
}
Cannot apply filter "ExportedFilter{filters=[JavaFilter(kotlinFilter=com.zhengchalei.jimmerdemo.TenantFilter@26994c6a)]}" for "com.zhengchalei.jimmerdemo.Book.author" because that property is not nullable
org.babyfish.jimmer.sql.runtime.ExecutionException: Cannot apply filter "ExportedFilter{filters=[JavaFilter(kotlinFilter=com.zhengchalei.jimmerdemo.TenantFilter@26994c6a)]}" for "com.zhengchalei.jimmerdemo.Book.author" because that property is not nullable
Cannot apply filter "ExportedFilter{filters=[JavaFilter(kotlinFilter=com.zhengchalei.jimmerdemo.TenantFilter@26994c6a)]}" for "com.zhengchalei.jimmerdemo.Book.author" because that property is not nullable org.babyfish.jimmer.sql.runtime.ExecutionException: Cannot apply filter "ExportedFilter{filters=[JavaFilter(kotlinFilter=com.zhengchalei.jimmerdemo.TenantFilter@26994c6a)]}" for "com.zhengchalei.jimmerdemo.Book.author" because that property is not nullable
从 AssociationIntegrityAssuranceFilter/KAssociationIntegrityAssuranceFilter允许用户对数据库的数据特色做出承诺,以打破这种限制。
这个结果是不是不符合预期