Skip to content

Commit

Permalink
HSEARCH-961 prevent exceptions for out of sync 2nd level caches and i…
Browse files Browse the repository at this point in the history
…ndexes
  • Loading branch information
Sanne authored and hferentschik committed Nov 11, 2011
1 parent 7d451aa commit 9884506
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.hibernate.search.util.logging.impl.Log;

import org.hibernate.Criteria;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.Session;
import org.hibernate.search.query.engine.spi.EntityInfo;
import org.hibernate.search.query.engine.spi.TimeoutManager;
Expand Down Expand Up @@ -64,8 +65,14 @@ public void initializeObjects(EntityInfo[] entityInfos,
if ( ObjectLoaderHelper.areDocIdAndEntityIdIdentical( entityInfo, session ) ) {
final boolean isIn2LCache = session.getSessionFactory().getCache().containsEntity( entityInfo.getClazz(), entityInfo.getId() );
if ( isIn2LCache ) {
//load the object from the second level cache
session.get( entityInfo.getClazz(), entityInfo.getId() );
try {
//load the object from the second level cache
session.get( entityInfo.getClazz(), entityInfo.getId() );
}
catch (ObjectNotFoundException onfe) {
// Unlikely but needed: an index might be out of sync, and the cache might be as well
remainingEntityInfos.add( entityInfo );
}
}
else {
remainingEntityInfos.add( entityInfo );
Expand Down

0 comments on commit 9884506

Please sign in to comment.