I understand that the entities are returned regardless of sessionCheckingEnabled when they are already in the Session. That is not the point. The point is efficiency. This up front check has overhead and there are cases where that overhead is not necessary. The "back end" check in Loader is not as big of a performance hit. The choice of sessionCheckingEnabled==false as the default is to avoid that overhead. I appreciate the investigation, but I assure you I understand what is going on here internally. Bottom line, the default value here is one of those 50/50 things. I am not going to change this outside of a very compelling argument (which is not what we have here). As for your points about DELETED, flushing, etc... multiLoad is designed to work like load (hence its name); it is not designed to work like Query. When you have an unflushed deletion in a Session, you can still load that entity:
Session session = openSession();
session.getTransaction().begin();
session.delete( session.load( SimpleEntity.class, 5 ) );
SimpleEntity s5 = session.load( SimpleEntity.class, 5 );
assertNotNull( s5 );
|