本文整理了Java中org.hibernate.ogm.model.spi.Association.clear()
方法的一些代码示例,展示了Association.clear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association.clear()
方法的具体详情如下:
包路径:org.hibernate.ogm.model.spi.Association
类名称:Association
方法名:clear
[英]Removes all rows from this association.
[中]删除此关联中的所有行。
代码示例来源:origin: hibernate/hibernate-ogm
@Override
public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
AssociationStorageStrategy storageStrategy = getAssociationStorageStrategy( key, associationContext );
Document document = storageStrategy == AssociationStorageStrategy.IN_ENTITY
? getEmbeddingEntity( key, associationContext )
: associationKeyToObject( key, storageStrategy );
Association association = new Association( new MongoDBAssociationSnapshot( document, key, storageStrategy ) );
// in the case of an association stored in the entity structure, we might end up with rows present in the
// current snapshot of the entity while we want an empty association here. So, in this case, we clear the
// snapshot to be sure the association created is empty.
if ( !association.isEmpty() ) {
association.clear();
}
return association;
}
代码示例来源:origin: org.hibernate.ogm/hibernate-ogm-mongodb
@Override
public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
AssociationStorageStrategy storageStrategy = getAssociationStorageStrategy( key, associationContext );
Document document = storageStrategy == AssociationStorageStrategy.IN_ENTITY
? getEmbeddingEntity( key, associationContext )
: associationKeyToObject( key, storageStrategy );
Association association = new Association( new MongoDBAssociationSnapshot( document, key, storageStrategy ) );
// in the case of an association stored in the entity structure, we might end up with rows present in the
// current snapshot of the entity while we want an empty association here. So, in this case, we clear the
// snapshot to be sure the association created is empty.
if ( !association.isEmpty() ) {
association.clear();
}
return association;
}
代码示例来源:origin: hibernate/hibernate-ogm
association.clear();
代码示例来源:origin: hibernate/hibernate-ogm
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();
}
}
}
}
代码示例来源:origin: org.hibernate.ogm/hibernate-ogm-couchdb
@Override
public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
CouchDBAssociation couchDBAssociation = null;
if ( isStoredInEntityStructure( key.getMetadata(), associationContext.getAssociationTypeContext() ) ) {
TuplePointer tuplePointer = getEmbeddingEntityTuplePointer( key, associationContext );
EntityDocument owningEntity = getEntityFromTuple( tuplePointer.getTuple() );
if ( owningEntity == null ) {
owningEntity = (EntityDocument) getDataStore().saveDocument( new EntityDocument( key.getEntityKey() ) );
tuplePointer.setTuple( new Tuple( new CouchDBTupleSnapshot( owningEntity ), SnapshotType.UPDATE ) );
}
couchDBAssociation = CouchDBAssociation.fromEmbeddedAssociation( tuplePointer, key.getMetadata() );
}
else {
AssociationDocument association = new AssociationDocument( Identifier.createAssociationId( key ) );
couchDBAssociation = CouchDBAssociation.fromAssociationDocument( association );
}
Association association = new Association( new CouchDBAssociationSnapshot( couchDBAssociation, key ) );
// in the case of an association stored in the entity structure, we might end up with rows present in the current snapshot of the entity
// while we want an empty association here. So, in this case, we clear the snapshot to be sure the association created is empty.
if ( !association.isEmpty() ) {
association.clear();
}
return association;
}
内容来源于网络,如有侵权,请联系作者删除!