Fetching eagerly on Lists 1:n
I have the following entities (simplified to illustrate):
Code:
class Profile {
@OneToMany(cascade = CascadeType.ALL)
List<Setting> settings = new ArrayList<Setting>();
// other properties
}
class Setting {
@ManyToOne
SettingDefinition definition;
// other properties
}
class SettingDefinition {
// some properties - no relationships defined here
}
When the list of Profiles is displayed on a GWT UI, all its properties are displayed fine. But the list of settings, have nulls for their definitions even if they do have non-null definitions referenced (I checked the db). I tried specifying this in the Setting entity:
Code:
@ManyToOne(fetch=FetchType.EAGER, optional=false)
and also increasing the hibernate.max_fetch_depth to more than three (AFAIK, 3 is the default), but I can't get the Setting entities from containing their corresponding Definition entities when they come from the server.
Is there any way to force these properties being fetched?
using Roo 1.2.1 with jpa ActiveRecord, hibernate, postgresql, gwt on ubuntu 11.04.