2016-07-01 69 views
1

我有這樣一組4臺設置如下:如何映射具有多個表上多個連接列的集合?

Table parent_a 
id | other_columns... 

Table parent_b 
id | filter | other_columns... 

Table child_a 
id | parent_id | other_columns... 

Table child_b 
id | filter | other_columns... 

的實體是設置如下:

@Entity 
@Table(name = "parent_a") 
@SecondaryTable(name = "parent_b") 
public class Parent { 
    @Id 
    @GeneratedValue 
    @Column(name = "id") 
    private Integer id; 

    @Column(name = "filter", table = "parent_b") 
    private String filter; 

    @OneToMany 
    @JoinColumns({ 
    @JoinColumn(name = "parent_id"), 
    @JoinColumn(name = "filter", table = "child_b") 
    }) 
    private List<Child> children; 
    // Mappings for other columns, getters/setters 
} 

@Entity 
@Table(name = "child_a") 
@SecondaryTable(name = "child_b") 
public class Child { 
    @Id 
    @GeneratedValue 
    @Column(name = "id") 
    private Integer id; 

    @Column(name = "filter", table = "child_b") 
    private String filter; 
    // Mappings for other columns, getters/setters 
} 

當我部署我的應用程序出現以下情況例外:

org.hibernate.cfg.NotYetImplementedException: Collections having FK in secondary table 

是否有另一種方法來獲取填充了基於父過濾器篩選的子實體的父實體?

回答

0

我用一個實體監聽器來填充父實體的加載集合。

相關問題