0

我需要加入 3 张桌子:

doc    
--------   
id   
id_user     


user      
--------   
id   
id_firm

firm     
--------      
id   

在 SQL 中,它给出:

SELECT * FROM DOC d join USER u on d.id_user=u.id join FIRM f on f.id=u.id_firm

我尝试:

@JoinTable(name = "user", 
    joinColumns = { @JoinColumn(name = "id_user", referencedColumnName = "id") })

但它不起作用(无限循环)。

4

1 回答 1

0

使用 inverseJoinColumns

@OneToMany(fetch=FetchType.EAGER)
@JoinTable( name = "user",
joinColumns         = { @JoinColumn(name = "ID_USER") },
inverseJoinColumns  = { @JoinColumn(name = "ID_FIRM") })
于 2013-06-29T20:27:54.017 回答