在我的模型中存在一对多关系,其中子实体存储在两个表中。
@Entity
@Table(name = "child1")
@SecondaryTable(name = "child2", pkJoinColumns = {
@PrimaryKeyJoinColumn(name = "id1", referencedColumnName = "id1"),
@PrimaryKeyJoinColumn(name = "id2", referencedColumnName = "id2")})
@Where(clause = "col1 is not null and col2 is not null")
@Data
@Immutable
public class Child implements Serializable {...}
Child
实体被急切地与
Parent
实体问题在于
@Where
col1
在桌子上
child1
和
col2
child2
ERROR 12333 --- [nio-8183-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper : Column (col2) not found in any table in the query (or SLV is undefined).
java.sql.SQLException: null
...
-
仅使用:
@Where(clause = "col1 is not null")
提供propper映射,结果没有错误。
-
@Where(clause = "child1.col1 is not null and child2.col2 is not null")
给出以下错误:
Column (child1) not found in any table in the query (or SLV is undefined).
@在哪里
使用两张桌子,或者是否有解决方法?
但也有一些要求:
-
我使用informix作为底层数据库,并且具有只读访问权限。
-