[jira] Commented: (OPENJPA-1913) If fetch-groups is used, detaching an entity will lead to all lazy loaded members get reset to null
[ https://issues.apache.org/jira/browse/OPENJPA-1913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978397#action_12978397 ] Jeremy Bauer commented on OPENJPA-1913: --- I did some debugging and a little more experimentation and I believe OpenJPA is working as designed. Using a DetachState of fgs results in a detached entity with only those fields in the specified fetch group. By default, OpenJPA uses the "default" fetch group and that fetch group contains primary keys, version fields, and eager fetch fields. If you apply a non-default fetch group (specified dynamically or via the openjpa.FetchGroups property) fields defined as EAGER - but not included in the specified fetch group - will not be included in detached entity (they'll be null). It is the correlation of EAGER/LAZY to the default fetch group that muddies the waters a bit. Also, one tends to think of fetch groups as a load operation, but in this case it applies to detachment as well. While it isn't terribly intuitive, using fgs may be useful if you are detaching and only want to provide a client an entity populated with only those fields defined in the fetch group. It sounds like what you may be looking for is a hybrid "loaded + fgs" option that preserves loaded fields and also loads any unloaded fields that are defined in the fetch group upon detachment. > If fetch-groups is used, detaching an entity will lead to all lazy loaded > members get reset to null > --- > > Key: OPENJPA-1913 > URL: https://issues.apache.org/jira/browse/OPENJPA-1913 > Project: OpenJPA > Issue Type: Bug > Components: kernel >Affects Versions: 2.1.0 >Reporter: Mark Struberg >Assignee: Jeremy Bauer > Fix For: 2.2.0 > > Attachments: OPENJPA-1913-enhancer-fix.patch, OPENJPA-1913-test.patch > > > If I use openjpa.DetachState=fetch-groups and detach an entity with a lazy > loaded list, this list gets reset to null. > An example: > class @Entity Person { >private String name; > @OneToMany(mappedBy = "group", cascade = {CascadeType.ALL}) > private List subscriptions = new ArrayList(); > ...} > I load the Person and access the subscriptions inside a transaction. I get a > person instance with e.g. 3 subscriptions. > If I now close the EntityManager and my person gets detached, the > subscriptions list is suddenly null! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (OPENJPA-1913) If fetch-groups is used, detaching an entity will lead to all lazy loaded members get reset to null
[ https://issues.apache.org/jira/browse/OPENJPA-1913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978405#action_12978405 ] Mark Struberg commented on OPENJPA-1913: hmm, interesting point. But of course, any non-specced openjpa feature must not break a spec conform CascadeType.DETACH and CascadeType.MERGE! This always must have priority over FetchGroups, otherwise we would break the spec. > If fetch-groups is used, detaching an entity will lead to all lazy loaded > members get reset to null > --- > > Key: OPENJPA-1913 > URL: https://issues.apache.org/jira/browse/OPENJPA-1913 > Project: OpenJPA > Issue Type: Bug > Components: kernel >Affects Versions: 2.1.0 >Reporter: Mark Struberg >Assignee: Jeremy Bauer > Fix For: 2.2.0 > > Attachments: OPENJPA-1913-enhancer-fix.patch, OPENJPA-1913-test.patch > > > If I use openjpa.DetachState=fetch-groups and detach an entity with a lazy > loaded list, this list gets reset to null. > An example: > class @Entity Person { >private String name; > @OneToMany(mappedBy = "group", cascade = {CascadeType.ALL}) > private List subscriptions = new ArrayList(); > ...} > I load the Person and access the subscriptions inside a transaction. I get a > person instance with e.g. 3 subscriptions. > If I now close the EntityManager and my person gets detached, the > subscriptions list is suddenly null! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (OPENJPA-1913) If fetch-groups is used, detaching an entity will lead to all lazy loaded members get reset to null
[ https://issues.apache.org/jira/browse/OPENJPA-1913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978407#action_12978407 ] Rick Curtis commented on OPENJPA-1913: -- @Mark -- I'm pretty sure that we have numerous OpenJPA 'features' that make us non-complaint... as long as your stay to javax.persistence.blah configuration, you'll stay compliant. Once you drop into OpenJPA specific stuff, all bets are off. > If fetch-groups is used, detaching an entity will lead to all lazy loaded > members get reset to null > --- > > Key: OPENJPA-1913 > URL: https://issues.apache.org/jira/browse/OPENJPA-1913 > Project: OpenJPA > Issue Type: Bug > Components: kernel >Affects Versions: 2.1.0 >Reporter: Mark Struberg >Assignee: Jeremy Bauer > Fix For: 2.2.0 > > Attachments: OPENJPA-1913-enhancer-fix.patch, OPENJPA-1913-test.patch > > > If I use openjpa.DetachState=fetch-groups and detach an entity with a lazy > loaded list, this list gets reset to null. > An example: > class @Entity Person { >private String name; > @OneToMany(mappedBy = "group", cascade = {CascadeType.ALL}) > private List subscriptions = new ArrayList(); > ...} > I load the Person and access the subscriptions inside a transaction. I get a > person instance with e.g. 3 subscriptions. > If I now close the EntityManager and my person gets detached, the > subscriptions list is suddenly null! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.