Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327900 - conform in unit of work queries return subclasses when read subclasses not enabled
Summary: conform in unit of work queries return subclasses when read subclasses not en...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: David Minsky CLA
QA Contact: Project Inbox CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-15 10:50 EDT by john.vandale CLA
Modified: 2022-06-09 10:03 EDT (History)
5 users (show)

See Also:


Attachments
fix and testcase (8.76 KB, patch)
2010-10-15 12:01 EDT, john.vandale CLA
david.minsky: iplog+
Details | Diff
fix and testcase which incorporates review comments (9.29 KB, patch)
2010-10-20 15:17 EDT, john.vandale CLA
david.minsky: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description john.vandale CLA 2010-10-15 10:50:54 EDT
Build Identifier: 

ReadAllQuery and ReadObjectQuery with conformResultsInUnitOfWork set will return subclasses of the query class type if instances of those subclasses are registered in the UoW despite the descriptor indication not to read subclasses. For example with ReadAllQuery the return set includes only the query class type instances from the DB but the query class and subclass type instances from the UoW.

Reproducible: Always
Comment 1 john.vandale CLA 2010-10-15 12:01:09 EDT
Created attachment 180981 [details]
fix and testcase
Comment 2 john.vandale CLA 2010-10-20 15:17:48 EDT
Created attachment 181333 [details]
fix and testcase which incorporates review comments
Comment 3 David Minsky CLA 2010-10-25 15:39:02 EDT
Initial checkin done in r8380:
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8380

Corrected checkin done in r8409:
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8409
Comment 4 Tor-Einar Jarnbjo CLA 2011-08-16 05:51:24 EDT
Please reopen.

The fix does not work properly if interface aliases are configured for the persistent classes. Consider e.g. the classes A and B with "B extends A" and their interface aliases IA and IB.

If I make a query for IB and an instance of B is found, the following expression in IdentityMapManager evaluates to false:

boolean readSubclassesOrNoInheritance = (!descriptor.hasInheritance() || descriptor.getInheritancePolicy().shouldReadSubclasses());

descriptor is here the class descriptor of B, which:

- hasInheritance() is true, since an InheritancePolicy instance is available
- shouldReadSubclasses() is false, since there are no further subclasses of B

Later in the same method, readSubclassesOrNoInheritance is used like this:

if ((object.getClass() == theClass) || (readSubclassesOrNoInheritance && (theClass.isInstance(object)))) {

We now have the issues that object.getClass() returns B.class, while theClass is IB.class. Since readSubclassesOrNoInheritance is false, the isInstance check (IB.class.isInstance(B.class) would have evaluated to true) does not cover the interface alias, as it did before this fix was applied.
Comment 5 Tom Ware CLA 2011-08-16 08:36:40 EDT
Please file a new bug including specifics about how to recreate, or how to alter the test case supplied with the fix for this bug to recreate the issue you are seeing.
Comment 6 Tor-Einar Jarnbjo CLA 2011-08-16 09:31:55 EDT
I can't find a download for the test framework, so it's a little bit difficult to write a new test case. I've however created bug 354822 and hope that the description is adequate.
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:03:42 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink