We have a Skyve document called NNSF - when an NNSF is created (saved) we need to create a record called a PAM which has an aggregation association to the NNSF.
So in the preSave() we have some code to do this:
PAM pam = PAM.newInstance();
// set a bunch of other attributes
...
// set an association to this NNSF
pam.setNnsf(bean);
The PAM record won't be saved automatically because it's not referenced by the NNSF document, so if we don't explicitly call CORE.getPersistence().save(pam) - the PAM is not saved to the DB even though the NNSF is.
If we do call CORE.getPersistence().save(pam) we get an infinite looping of the preSave() because the PAM has an association to this NNSF.
If we call CORE.upsertBeanTuple(pam) instead, we get FK constraint violation as you would expect, because of the association to the NNSF.