Is multi-level fetch depth with RequestFactory possible?

65 views
Skip to first unread message

Rogelio Flores

unread,
Mar 20, 2012, 3:22:30 PM3/20/12
to google-we...@googlegroups.com
I have an issue that might be JPA/Hibernate-related, but it could also be related to RequestFactory, so bear with me pls:

I have the following JPA @Entity-s:

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 a list of Profiles is displayed on a GWT UI (produced by Spring Roo, which uses RequestFactory), all their properties are displayed fine, except the individual Settings in the List have null SettingDefinitions even if they're not null in the db (I checked). I tried fetching eagerly and forcing it to not be null with:

@ManyToOne(fetch=FetchType.EAGER, optional=false)
SettingDefinition definition;

and also increasing the hibernate.max_fetch_depth to more than three (AFAIK, 3 is the default), but I can't get the Settings to have their corresponding SettingDefinitions when they come from the server. Is there a setting or something that can be done to force these referenced entities so that they are fetched?

(I posted this issue on the Roo forum but I've seen no response there:
http://forum.springsource.org/showthread.php?124490-Fetching-eagerly-on-Lists-1-n If this can be solved by the RequestFactory framework, this should be the right place to ask).

Alfredo Quiroga-Villamil

unread,
Mar 20, 2012, 3:38:10 PM3/20/12
to google-we...@googlegroups.com
Rogelio:

This is likely in the Roo/Hibernate question, more hibernate than Roo. I replied to you in the Spring forum. We'll come back here if we see that's GWT related. I suspect is not.

Best regards,

Alfredo

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM:  lawwton


Jesse Hutton

unread,
Mar 20, 2012, 4:02:08 PM3/20/12
to google-we...@googlegroups.com
What does your request look like? It should be something like
myRequestFactory.profileRequest.fetchProfile(id).with("settings.definition").
All of the relations returned via request factory must be explicitly
asked for.

Jesse

On Tue, Mar 20, 2012 at 3:22 PM, Rogelio Flores
<rogelio...@gmail.com> wrote:

Thomas Broyer

unread,
Mar 20, 2012, 6:55:51 PM3/20/12
to google-we...@googlegroups.com
Are you passing "settings.settingDefinition" to the with() of your Request? If not (only giving "settings") then that's expected.

El Mentecato Mayor

unread,
Mar 20, 2012, 9:45:48 PM3/20/12
to Google Web Toolkit
Thanks guys! That was it, I assumed those relationships would be
fetched automatically.
Reply all
Reply to author
Forward
0 new messages