Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 如何将Where子句应用于辅助表_Hibernate_Annotations - Fatal编程技术网

Hibernate 如何将Where子句应用于辅助表

Hibernate 如何将Where子句应用于辅助表,hibernate,annotations,Hibernate,Annotations,我用一个主表和两个关联表创建了一个实体。我使用hibernate注释加入了主从表。 这是代码 @Entity @Table(name = "Table1") @org.hibernate.annotations.Entity(dynamicUpdate=true) @org.hibernate.annotations.Tables ( { @org.hibernate.annotations.Table(appliesTo = "Table2", optional = false ),

我用一个主表和两个关联表创建了一个实体。我使用hibernate注释加入了主从表。 这是代码

@Entity
@Table(name = "Table1")
@org.hibernate.annotations.Entity(dynamicUpdate=true)
@org.hibernate.annotations.Tables ( {
    @org.hibernate.annotations.Table(appliesTo = "Table2", optional = false ),
    @org.hibernate.annotations.Table(appliesTo = "Table3", optional = false )
})
//@org.hibernate.annotations.Table(appliesTo = "Table2", optional = false )
@PrimaryKeyJoinColumn(name="t1_column1")
@SecondaryTables({
    @SecondaryTable(name = "Table2", pkJoinColumns = {@PrimaryKeyJoinColumn(name = "t2_col1", referencedColumnName = "t1_col1")}  ),
    @SecondaryTable(name = "Table3", pkJoinColumns = {@PrimaryKeyJoinColumn(name = "t3_col1", referencedColumnName = "t1_col1")})
})
这个很好用。我想指定一个Where注释,该注释将应用于次表“Table2”。默认情况下,hibernate注释“@Where”仅应用于目标表,此处为“Table1”。结果,我得到一个SQL错误,在“Table1”中找不到where子句中包含的列


是否有任何特殊指令需要添加到@Where,以使hibernate在辅助表Table2上添加SQL Where子句?

我想@Where和@WhereJoinTable就是您想要的

这看起来像是一个已知的问题-我还没有找到修复方法