We're updating the issue view to help you get more done. 

Missing result when using polymorphism and second level cache

Description

(We are working on a test case.)

From my post on the list:

We have a weird problem here with Search 4.3 and ORM 4.2.7.SP1. I wonder if it rings a bell for anyone?

In yet to determined circumstances, an object is missing from the search results. This object is returned by the Lucene search but is not added in the results because it isn't initialized. In ObjectLoaderHelper.returnAlreadyLoadedObjectsInCorrectOrder(), there is a test to check if the element is initialized before including it in the results list. The fact is that sometimes, the element is a Javassist proxy (we use ehcache) and isn't initialized at all even if it exists in the database. Thus it's not included in the results.

A few more comments:

  • if we force the initialization with the IDE by inspecting the object before the test, the element is included and everything works fine;

  • if we use the SecondLevelCacheObjectsInitializer (by calling fullTextQuery.initializeObjectsWith(ObjectLookupMethod.SECOND_LEVEL_CACHE, DatabaseRetrievalMethod.QUERY) instead of the Criteria one, everything works fine too.

I'm wondering if this test is legit and if the assertion that the object should be initialized here or doesn't exist in the database is really true, especially when the object is cached and is a Javassist proxy.

We have a workaround but I'm pretty sure there's a bug somewhere.

Environment

None

Status

Assignee

Hardy Ferentschik

Reporter

Guillaume Smet

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Fix versions

Affects versions

4.3.0.Final
4.4.0.Final
4.5.0.Alpha1

Priority

Major