openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henno Vermeulen <he...@huizemolenaar.nl>
Subject RE: questions about FetchAttribute recursionDepth
Date Wed, 06 Apr 2011 07:47:26 GMT
The detach-related settings in persistence.xml we use are:

	<property name="openjpa.DetachState" value="fetch-groups(DetachedStateField=false)" />
	<property name="openjpa.AutoDetach" value="commit" />

In almost all our use cases the fetched entities are serialized and sent to a remote client.
The client is currently not required to have OpenJPA on its classpath (although it does use
enhanced entities).

Henno

-----Oorspronkelijk bericht-----
Van: Michael Dick [mailto:michael.d.dick@gmail.com] 
Verzonden: dinsdag 5 april 2011 21:45
Aan: users@openjpa.apache.org
Onderwerp: Re: questions about FetchAttribute recursionDepth

Hi Henno,

Have you set the openjpa.DetachState property or are you using the default
value?

-mike

On Tue, Apr 5, 2011 at 11:17 AM, Henno Vermeulen <henno@huizemolenaar.nl>wrote:

> I suspect this is an issue with detaching!
>
> I turned on the trace and printed a message after entityManager.find.
> When I have a structure of 10 levels deep and fetch the deepest child,
> OpenJPA cleanly fetches the leaf ProductCategory with 1 query, then prints
> my message, but then starts recursively fetching all parents.
>
> When I set the recursionDepth to 2 the SQL shows that it fetches one more
> parent, then print my debug message, then fetch the rest.
>
> Is this a known problem or should I report this?
>
> Regards,
> Henno Vermeulen
> Huize Molenaar.
>
> -----Oorspronkelijk bericht-----
> Van: Henno Vermeulen [mailto:henno@huizemolenaar.nl]
> Verzonden: dinsdag 5 april 2011 17:42
> Aan: 'users@openjpa.apache.org'
> Onderwerp: questions about FetchAttribute recursionDepth
>
> I have a ProductCategory entity with a reference to a parent
> ProductCategory. I wish to eagerly fetch one parent but not the parent's
> parent. We always use fetchplans (using
> entityManager.getFetchPlan().addFetchGroups(...)) and we always detach
> according to the fetchplan, so I tried:
>
> @FetchGroup(name = "ProductCategoryParentNoRecursion", attributes = {
> @FetchAttribute(name = "parent", recursionDepth = 1) })
>
> Question 1: according to the latest manual a recursionDepth of 1 is the
> default, but I have also seen it mentioned in Jira or the newsgroup that it
> was changed so that the recursion depth has no limit by default. Which one
> is it?
>
> Question 2: no matter what recursionDepth I use (I tried -1, 0, 1 and 2),
> it always fetches the parent's parent. I tested this with a ProductCategory
> structure of A -> B -> C. When I use entityManager.find to find C by it's
> id, I expect C.parent.parent to be null but it is not. Why is this?
> (I did not access the parent before detaching).
>
> Regards,
>
> Henno Vermeulen
> Huize Molenaar
>

Mime
View raw message