Fixed the computation of the max position for new association groups

The call to persist for the related grouping association may be done after persisting the sortable item.
Fixes #883

The implementation is specific to the ORM, but the whole listener is ORM-specific already anyway.