【问题标题】:@Where not working with @onetoone in hibernate@Where 不使用 @onetoone 在休眠
【发布时间】:2012-12-03 05:39:24
【问题描述】:

我有一个要求,应该根据特定条件获取@OneToOne 关联。

class Entity2 {
    @OneToOne
    @Where(clause="epoch_end_time > current_timestamp() ")
    @JoinColumn(name="program_index",insertable=false,updatable=false,nullable=false)
    private ProgramHistory pgmHistory;
} 

class Entity1 {

@OnetoMany
@JoinColumn(...........)
private Entity2 entity;

}

当我执行“from Entity1”时..Hibernate 创建具有如下条件的查询“..........,Entity2.proram_index = ProgramHistory.program_index”...但我需要@Where 子句也必须作为此查询的一部分添加。但是休眠似乎从来没有添加它。知道吗? @Where..我的案例 epoch_end_time 是 ProgramHistory 表中的一个 coloum。

@Where 与@OneToMany 一起工作得很好......但我的要求是将条件放在@OneToOne 的关联实体中。 @Filter 会有帮助吗?文档中说 @Where 和 @Filter 是为了收集。

【问题讨论】:

    标签: hibernate jpa hql


    【解决方案1】:

    @Where 和 @Filter 用于收集。因此它不适用于 @OneToOne。

    【讨论】:

      猜你喜欢
      • 2011-05-21
      • 2011-02-25
      • 2011-02-13
      • 2012-08-11
      • 2021-06-25
      • 2012-10-14
      • 2012-07-30
      • 2014-12-27
      相关资源
      最近更新 更多