Hibernate @Subselect一对多字段

时间:2014-12-09 10:58:50

标签: java hibernate

我有类似的东西:

@Entity
public class First {

    <...>

    @OneToMany
    @JoinColumn(name = "first-id", nullable = false)
    private List<Second> seconds = new ArrayList<Second>();
}

@Entity
@Subselect(...)
public class FirstView {

    <...>

    private List<Second> seconds = new ArrayList<Second>();        
}

如何在FirstView.seconds上加载session.createCriteria(FirstView.class).add(<...>).list()

1 个答案:

答案 0 :(得分:0)

seconds中的

FirstView应以与First中省略不足部分相同的方式进行注释。在给定的情况下,它看起来如此:

    @OneToMany
    @JoinColumn(name = "first-id")
    private List<Second> seconds = new ArrayList<Second>();