Queries Returning Incorrect Data With Toplink 12 - Worked Fine With Toplink 10.1.3.4 (Doc ID 1900004.1)

Last updated on JUNE 25, 2014

Applies to:

Oracle TopLink - Version 12.1.2.0.0 and later
Information in this document applies to any platform.

Symptoms

Toplink queries not returning the correct data in the current version of Toplink. The functionality worked correctly in Toplink 10.1.3.4.
This issue stopped working when upgrading to Toplink 12.

Here is technical summary of the issue extracted from the bug Test Case

The line that states 'Retrieving children by Parent IDFR:' is printed
right before the TstChild object is retrieved from the database based on its
parent idfr.

After both TstChild objects are retrieved, the TstParent object is
obtained through the one-to-one mapping back to the parent. The parent
idfr is then compared to the idfr that is passed in as an argument
to the query.

When using TopLink 10g we see that the TstChild retrieved always
matches the expected one. However, when using TopLink 12c the
second TstChild retrieved is the same one as the first one retrieved.

Note: InMemoryQueryIndirectionPolicy is configured to throw an indirection exception
(InMemoryQueryIndirectionPolicy.SHOULD_THROW_INDIRECTION_EXCEPTION).

Stepping through the EclipseLink code it looks like in
ExpressionQueryMechanism.checkCacheForObject
while checking the cache on the second query that there is code present that
if 'Conform Results in Unit of Work' is enabled and the
InMemoryQueryIndirectionPolicy is not
SHOULD_TRIGGER_INDIRECTION it changes the policy to
SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED.

Eventually IdentityMapManager.getFromIdentityMap is invoked where it attempts
to
go through the elements in the cache looking for the element in the query.
While checking
doesConform against the already read back TstChild object a
MUST_INSTANTIATE_VALUEHOLDERS
exception is thrown (since the TstChild.getParent() method has not yet been
invoked initializing the Value

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms