That's been taken care of: if b is new, the fk in a is synced after b is saved, otherwise it's synced right after the assignment.
After the assignment, you also only have to save a (using a recursive save, default in adapter), and b is saved automatically as well, in the right order (so first b, then a).