diff --git a/core/src/main/java/org/hibernate/ogm/persister/OgmCollectionPersister.java b/core/src/main/java/org/hibernate/ogm/persister/OgmCollectionPersister.java index 30f4f0c014..5d6261f2c8 100644 --- a/core/src/main/java/org/hibernate/ogm/persister/OgmCollectionPersister.java +++ b/core/src/main/java/org/hibernate/ogm/persister/OgmCollectionPersister.java @@ -687,27 +687,31 @@ public void remove(Serializable id, SessionImplementor session) throws Hibernate .collectionPersister( this ) .session( session ); - // shortcut to avoid loop if we can - if ( associationType != AssociationType.OTHER ) { - for ( RowKey assocEntryKey : associationPersister.getAssociation().getKeys() ) { - // we unfortunately cannot mass change the update of the associated entity - updateInverseSideOfAssociationNavigation( - session, - null, - associationPersister.getAssociation().get( assocEntryKey ), - Action.REMOVE, - assocEntryKey - ); + Association association = associationPersister.getAssociationOrNull(); + + if ( association != null ) { + // shortcut to avoid loop if we can + if ( associationType != AssociationType.OTHER ) { + for ( RowKey assocEntryKey : association.getKeys() ) { + // we unfortunately cannot mass change the update of the associated entity + updateInverseSideOfAssociationNavigation( + session, + null, + association.get( assocEntryKey ), + Action.REMOVE, + assocEntryKey + ); + } } - } - associationPersister.getAssociation().clear(); + association.clear(); - if ( associationPersister.hostingEntityRequiresReadAfterUpdate() ) { - Object owner = session.getPersistenceContext().getCollectionOwner( id, this ); - associationPersister.hostingEntity( owner ); - } + if ( associationPersister.hostingEntityRequiresReadAfterUpdate() ) { + Object owner = session.getPersistenceContext().getCollectionOwner( id, this ); + associationPersister.hostingEntity( owner ); + } - associationPersister.flushToCache(); + associationPersister.flushToCache(); + } if ( log.isDebugEnabled() ) { log.debug( "done deleting collection" ); diff --git a/core/src/main/java/org/hibernate/ogm/util/impl/AssociationPersister.java b/core/src/main/java/org/hibernate/ogm/util/impl/AssociationPersister.java index 584135e8a6..dbe688503c 100644 --- a/core/src/main/java/org/hibernate/ogm/util/impl/AssociationPersister.java +++ b/core/src/main/java/org/hibernate/ogm/util/impl/AssociationPersister.java @@ -408,8 +408,6 @@ private void updateHostingEntityIfRequired() { * Whether the association in question is stored within an entity structure ("embedded") and this entity has * properties whose value is generated in the datastore (such as a version attribute) or not. * - * @param metadataProvider persister of the association - * @param ownerPersister persister of the owning entity * @return {@code true} in case the represented association is stored within an entity which has server-generated * properties, and thus must be re-read after an update to the association, {@code false} otherwise. */