开发者

Hibernate not populate data from mapping table

I have User class and Country class with respective tables. Country table data is fixed. I make a mapping table User_Country(userid, countryid) and following mapping in User class

 @OneToMany(fetch=FetchType.EAGER)
    @JoinTable(name = "User_Country", joinColumns ={
            @JoinColumn(name = "userid")
        }, inverseJoinColumns = {
            @JoinColumn(name = "COUNTRYID")
    })
private Set<Country> country;

When i persist User class it successfully persist user data and insert data in mapping table(user_country). This is exactly i want but when i find User by using hql('from user where userid=?') and then try to get country maaping (which is stored in map开发者_运维百科ping tableuser_country). I didn't get any data from user_country. How can i write annotation so that it gets data from user_country. If i put cascade then it update country table(which is fixed) which i don't want.


I am not too sure but, try with inverse="false", as that might help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜