|
I disagree about the POLA here. To me its utterly surprising to try to load a known "wrong class" and simply get null in return.
But I do agree it should be consistent/transparent. I really have no horse in the race as to whether that means throw an exception or return null. I just in general find returning null in known exception cases to be quite often counterproductive.
E.g., consider (using model from
HHH-9028
):
AccountManager u = session.get( AccountManager.class, 1 );
session.save( new AccountManager( 1, .. ) );
but of course the save goes boom.
Anyway, in the interest of consistent behavior (transparency) and because loading from the session cache (for get, as discussed on
HHH-9107
) as well as loading from the db... I am ok with going with returning null here if y'all feel strongly that is the right thing to do.
|