final FullTextSession fullTextSession = Search.getFullTextSession( session );
//load just one object into persistence context:
List firstLoad = session.createQuery( "from Kernel k where k.codeName = 'coconut'" ).list();
assertThat( firstLoad.size() ).isEqualTo( 1 );
statistics.clear();
final QueryBuilder queryBuilder = fullTextSession.getSearchFactory()
.buildQueryBuilder()
.forEntity( Kernel.class )
.get();
final Query luceneQuery = queryBuilder.keyword().onField( "product" ).matching( "Polgeiser" ).createQuery();
final FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery, Kernel.class );
fullTextQuery.initializeObjectsWith( ObjectLookupMethod.SECOND_LEVEL_CACHE, DatabaseRetrievalMethod.QUERY );
List list = fullTextQuery.list();
assertThat( list.size() ).isEqualTo( 2 );
assertThat( statistics.getSecondLevelCacheHitCount() )