I'm having a hard time visualising the difference between shallow clone and deep clone in apex, for example
Account acct = [SELECT Id, Name, Rating, ParentId FROM Account WHERE Id = '0010O00001qEu5cQAC'][0];
//specifying false for isDeepClone parameter
Account acctDeepClone = acct.clone(false,false);
acctDeepClone.Name = 'DeepClone2';
update acct;
Changing the account name of the shallow clone and then updating the original does nothing to the original, the original name remains.
Also, I cannot update acctDeepClone because it doesn't have an Id field.
If I change my code to the following
Account acct = [SELECT Id, Name, Rating, ParentId FROM Account WHERE Id = '0010O00001qEu5cQAC'][0];
//specifying true for isDeepClone parameter
Account acctDeepClone = acct.clone(false,true);
acctDeepClone.Name = 'DeepClone2';
update acct;
I see the exact same behaviour as in the first snippet, the original account is never updated, and I cannot update the cloned version.
Can someone please show a concrete example (no theory) of how these two really look like?