@Steve Ebersole One of reasons multiLoad method will return entity which associated with the session if exists; even enableSessionCheck == false. It depends on getRow() method in Loader.class. Check line of 1539 in Loader.class out.
object = session.getEntityUsingInterceptor( key );
if ( object != null ) {
instanceAlreadyLoaded(
rs,
i,
persisters[i],
key,
object,
lockModes[i],
session
);
Below test case is a result.
SimpleEntity third = session.byId( SimpleEntity.class ).load( 3 );
third.setText("changed entity");
List<SimpleEntity> list = session.byMultipleIds(SimpleEntity.class)
.enableSessionCheck(false)
.multiLoad( Arrays.asList( 1, 2, 3, 4, 5 ) );
assertEquals("changed entity", list.get(2).getText());
Changed the text in third entity which associated with session. when executing multiLoad() this changing was not flushed yet, also id:3 would be included in selection of query. ; enableSessionCheck(false); but results has a changed entity in session. As a result even enableSessionCheck == false, returned entities are associated with session. Then including ids which already are associated with Session, don't need to include in selection of query. I think enableSessionCheck(true); is better than false |