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

Bug 354822

Summary: IdentityMapManager does not find cached, inherited objects if querying for the object's interface alias
Product: z_Archived Reporter: Tor-Einar Jarnbjo <tor.jarnbjo.ext>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: NEW --- QA Contact:
Severity: major    
Priority: P2 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Tor-Einar Jarnbjo CLA 2011-08-16 09:16:46 EDT
Build Identifier: 2.2.0

The fix for Bug 327900 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, with:

- 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 issue 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.


Reproducible: Always

Steps to Reproduce:
1. Create two inherited entities A and B, where B extends A. Let B have an interface alias IB.
2. Create an instance of B with some data, so that it can be queried from the identity map cache. Do not persist or commit to the database.
3. Run a query for IB with an expression matching the data of the newly created B instance. The expected behaviour is that the cached instance of B is returned, however the query does not return any results.
Comment 1 Tom Ware CLA 2011-09-09 09:07:17 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:21:43 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink