Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322681

Summary: FetchGroupManager.shouldWriteInto is wrong
Product: z_Archived Reporter: Andrei Ilitchev <andrei.ilitchev>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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