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 mapping 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.