Search code examples
javaopenjpa

OpenJPA @FetchGroup


I am using @FetchGroup to load category data, each category may or may not have parent/ child category.
*I only need 2 level of data, which means Category -> sub level1 -> sub level 2 *I do not want to fetch the complete try of category, since that will affect the performance. I add @FetchGroup(name = FetchGroupConstants.CATEGORY_CHILD_LEVEL_2, attributes = { @FetchAttribute(name = "children", recursionDepth = 2) }) at the entity class. Then I also used the following group to fetch the data

@FetchGroup(name = FetchGroupConstants.CATEGORY_BASIC, attributes = { @FetchAttribute(name = "ordering"), @FetchAttribute(name = "catalog") }),

Then I got the complete tree. The same result as "recursionDepth = -1". If I set recursionDepth = 1, I also get the complete tree. I am using "FetchPlan" What is the problem? Thanks.


Solution

  • Give up. I use fetch the whole tree into server's cache for now an. Any suggestion.