Hi,
We have used Hibernate 3 with annotation based mapping. Hibernate by default does Lazy Loading on all associations. We have implemented a one-to-many relationship through a join table. The problem here is the associations are always eagerly loaded until I explicitly set fetch=FetchType.LAZY ? Is this required ? Shouldn't hibernate load it lazily by default ?
Code:
public class User{
@OneToMany
@JoinTable(name = "user_system", joinColumns = {
@JoinColumn(name = "user_id", unique = true)
},
inverseJoinColumns = {
@JoinColumn(name = "system_id")
}
)
private List<System> systems = new ArrayList<System>();
}
public class System{
@ManyToOne
@JoinTable(name = "user_system",
joinColumns = {@JoinColumn(name = "system_id", unique = true)},
inverseJoinColumns = {@JoinColumn(name = "user_id")}
)
private User user;
}