[hibernate-dev] [SEARCH] Result ignored if proxy isn't initialized

Guillaume Smet guillaume.smet at gmail.com
Mon Nov 4 13:26:49 EST 2013


Hi,

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.

cc: Yoann which is working on the project where we met this bug today.

Thanks for your feedback.

-- 
Guillaume


More information about the hibernate-dev mailing list