@Override public int getSize(Serializable key, SharedSessionContractImplementor session) { AssociationPersister associationPersister = getAssociationPersister( session.getPersistenceContext().getEntity( new org.hibernate.engine.spi.EntityKey( key, getOwnerEntityPersister() ) ), key, session ); final Association collectionMetadata = associationPersister.getAssociationOrNull(); return collectionMetadata == null ? 0 : collectionMetadata.size(); }
private void removeNavigationalInformationFromInverseSide(int propertyIndex, AssociationKeyMetadata associationKeyMetadata, Object[] oldColumnValue) { // If the association involves entities deleted by a previous operation of the current batch, // it does not make sense trying to update association itself EntityKey entityKey = new EntityKey( associationKeyMetadata.getEntityKeyMetadata(), oldColumnValue ); if ( gridDialect instanceof BatchOperationsDelegator && ( (BatchOperationsDelegator) gridDialect ).isMarkedForRemoval( entityKey ) ) { return; } AssociationPersister associationPersister = createInverseAssociationPersister( propertyIndex, associationKeyMetadata, oldColumnValue ); Association association = associationPersister.getAssociationOrNull(); // The association might be empty if the navigation information have already been removed. // This typically happens when the entity owning the inverse association has already been deleted prior to // deleting the entity owning the association and a {@code @NotFound(action = NotFoundAction.IGNORE)} is // involved. if ( association != null && !association.isEmpty() ) { RowKey rowKey = getInverseRowKey( associationKeyMetadata, oldColumnValue ); association.remove( rowKey ); associationPersister.flushToDatastore(); } }
Association association = associationPersister.getAssociationOrNull();
.build(); final Association ids = associationPersister.getAssociationOrNull();
private void removeNavigationInformation(Serializable id, Object entity, SharedSessionContractImplementor session) { for ( int propertyIndex = 0; propertyIndex < getEntityMetamodel().getPropertySpan(); propertyIndex++ ) { if ( propertyMightHaveNavigationalInformation[propertyIndex] ) { CollectionType collectionType = (CollectionType) getPropertyTypes()[propertyIndex]; OgmCollectionPersister collectionPersister = (OgmCollectionPersister) getFactory() .getMetamodel().collectionPersister( collectionType.getRole() ); AssociationPersister associationPersister = new AssociationPersister.Builder( collectionPersister.getOwnerEntityPersister().getMappedClass() ) .hostingEntity( entity ) .gridDialect( gridDialect ) .key( id, collectionPersister.getKeyGridType() ) .associationKeyMetadata( collectionPersister.getAssociationKeyMetadata() ) .associationTypeContext( collectionPersister.getAssociationTypeContext() ) .session( session ) .build(); Association association = associationPersister.getAssociationOrNull(); if ( association != null && !association.isEmpty() ) { association.clear(); associationPersister.flushToDatastore(); } } } }
.build(); Association assoc = associationPersister.getAssociationOrNull(); if ( assoc != null ) { for ( RowKey rowKey : assoc.getKeys() ) {