only call isDirty on persistent collection

add missing checks if a collection is a PersistentCollection.

fix #416 

@dantleech, would you manage to figure out a minimal PR that triggers the problem, so we can be sure this is actually fixing something.