Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354822 - IdentityMapManager does not find cached, inherited objects if querying for the object's interface alias
Summary: IdentityMapManager does not find cached, inherited objects if querying for th...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-16 09:16 EDT by Tor-Einar Jarnbjo CLA
Modified: 2022-06-09 10:21 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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