diff --git a/api/src/main/java/org/openmrs/api/db/hibernate/AuditableInterceptor.java b/api/src/main/java/org/openmrs/api/db/hibernate/AuditableInterceptor.java index cc922a58aa55..d3b576a40f79 100644 --- a/api/src/main/java/org/openmrs/api/db/hibernate/AuditableInterceptor.java +++ b/api/src/main/java/org/openmrs/api/db/hibernate/AuditableInterceptor.java @@ -17,7 +17,7 @@ import org.hibernate.CallbackException; import org.hibernate.EmptyInterceptor; -import org.hibernate.collection.spi.PersistentCollection; +import org.hibernate.collection.internal.PersistentSet; import org.hibernate.type.Type; import org.openmrs.Auditable; import org.openmrs.OpenmrsObject; @@ -183,9 +183,9 @@ private boolean changePropertyValue(Object[] currentState, String[] propertyName } private void handleCollectionChange(Object collection) { - if (collection instanceof PersistentCollection) { - PersistentCollection persistentCollection = (PersistentCollection) collection; - if (persistentCollection.getKey().equals("role")) { + if (collection instanceof PersistentSet) { + PersistentSet persistentCollection = (PersistentSet) collection; + if ("org.openmrs.User.roles".equals(persistentCollection.getRole())) { Object owner = persistentCollection.getOwner(); if (owner instanceof User) { User user = (User) owner;