I was trying to retrieve
manager.Name going up in hierarchy I also tried to retrieve
manager.Name was null so I was expecting it to throw an exception. However I didn't got any exception.
I tried following code on Developer console:
List<User> userList = [Select manager.Name, manager.Mobile_number__c, manager.manager.Name, manager.manager.Mobile_number__c, manager.Email, manager.manager.Email, manager.manager.manager.Email from User where id = '005900000018D73']; System.debug('1. : '+ userList.get(0).manager); //if manager is getting NULL System.debug('2. : '+ userList.get(0).manager.manager); // NULL.manager is/should not possible ?! System.debug('3. : '+ userList.get(0).manager.manager.manager);
What I was expecting that it should throw an Exception:
Attempt to de-reference NULL object.
Observation: It runs successfully with no errors.
Can anyone explain why it's happening like this?