Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322681 - FetchGroupManager.shouldWriteInto is wrong
Summary: FetchGroupManager.shouldWriteInto is wrong
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-13 14:27 EDT by Andrei Ilitchev CLA
Modified: 2022-06-09 10:20 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Ilitchev CLA 2010-08-13 14:27:10 EDT
The method suppose to return true if the clone has a fetch group, which doesn't cover the fetch group of the source object (there is at least one attribute in source fetch group that is not in target fetch group).

Currently:
    public boolean shouldWriteInto(Object cachedObject, Object clone) {
        if (isPartialObject(clone)) {
            FetchGroup fetchGroupInSrc = ((FetchGroupTracker)cachedObject)._persistence_getFetchGroup();
            FetchGroup fetchGroupInTarg = ((FetchGroupTracker)clone)._persistence_getFetchGroup();

            //if the target fetch group is not null (i.e. fully fetched object) or if partially fetched, it's not a superset of that of the source, 
            //or if refresh is required, should always write (either refresh or revert) data from the cache to the clones.
            return fetchGroupInTarg != null || fetchGroupInTarg.isSupersetOf(fetchGroupInSrc) || ((FetchGroupTracker) cachedObject)._persistence_shouldRefreshFetchGroup();
        }
        return false;
    }

Should be:
    public boolean shouldWriteInto(Object cachedObject, Object clone) {
        FetchGroup fetchGroupInTarg = ((FetchGroupTracker)clone)._persistence_getFetchGroup();
        if (fetchGroupInTarg != null) {
            FetchGroup fetchGroupInSrc = ((FetchGroupTracker)cachedObject)._persistence_getFetchGroup();

            //should write if target's fetch group is not a superset of that of the source, 
            //or if refresh is required, should always write (either refresh or revert) data from the cache to the clones.
            return !fetchGroupInTarg.isSupersetOf(fetchGroupInSrc) || ((FetchGroupTracker) cachedObject)._persistence_shouldRefreshFetchGroup();
        }
        return false;
    }


Note that 
        if (isPartialObject(clone)) {
is identical to
        if (fetchGroupInTarg != null) {
Comment 1 Andrei Ilitchev CLA 2010-08-13 15:17:53 EDT
The patch checked into trunk and 2.1.1
Reviewed by James.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:20:56 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink