Deduplicated code for ColumnGroup and Document persistence.