The method
SimpleNaturalIdLoadAccess.getReference(Object naturalIdValue)
is documented with
"@return the persistent instance or proxy"
This is wrong. The method returns null if the entity is not found.
See implementation
@Override
public Object getReference(Object naturalIdValue) {
final Serializable entityId =
resolveNaturalId( getNaturalIdParameters( naturalIdValue ) );
if ( entityId == null ) {
return null;
}
return this.getIdentifierLoadAccess().getReference( entityId );
}
TestCase:
getSession().bySimpleNaturalId(User.class).getReference("NO_USER_WITH_THIS_NAME");
|