本文整理汇总了Java中org.hibernate.search.bridge.StringBridge类的典型用法代码示例。如果您正苦于以下问题:Java StringBridge类的具体用法?Java StringBridge怎么用?Java StringBridge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringBridge类属于org.hibernate.search.bridge包,在下文中一共展示了StringBridge类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: delete
import org.hibernate.search.bridge.StringBridge; //导入依赖的package包/类
@Override
public void delete(
Class<?> entityClass,
List<Class<?>> inIndexOf,
Object id,
EntityProvider entityProvider,
Transaction tx) {
for ( Class<?> indexClass : inIndexOf ) {
RehashedTypeMetadata metadata = IndexUpdater.this.metadataForIndexRoot.get( indexClass );
List<String> fields = metadata.getIdFieldNamesForType().get( entityClass );
for ( String field : fields ) {
DocumentFieldMetadata metaDataForIdField = metadata.getDocumentFieldMetadataForIdFieldName().get(
field
);
SingularTermDeletionQuery.Type idType = metadata.getSingularTermDeletionQueryTypeForIdFieldName()
.get( entityClass );
Object idValueForDeletion;
if ( idType == SingularTermDeletionQuery.Type.STRING ) {
FieldBridge fb = metaDataForIdField.getFieldBridge();
if ( !(fb instanceof StringBridge) ) {
throw new IllegalArgumentException( "no TwoWayStringBridge found for field: " + field );
}
idValueForDeletion = ((StringBridge) fb).objectToString( id );
}
else {
idValueForDeletion = id;
}
if ( indexClass.equals( entityClass ) ) {
this.searchIntegrator.getWorker().performWork(
new Work(
entityClass,
(Serializable) id,
WorkType.DELETE
), tx
);
}
else {
HSQuery hsQuery = this.searchIntegrator
.createHSQuery()
.targetedEntities( Collections.singletonList( indexClass ) )
.luceneQuery(
this.searchIntegrator.buildQueryBuilder()
.forEntity( indexClass )
.get()
.keyword()
.onField( field )
.matching( idValueForDeletion )
.createQuery()
);
int count = hsQuery.queryResultSize();
int processed = 0;
// this was just contained somewhere
// so we have to update the containing entity
while ( processed < count ) {
for ( EntityInfo entityInfo : hsQuery.firstResult( processed ).projection(
ProjectionConstants.ID
).maxResults( HSQUERY_BATCH )
.queryEntityInfos() ) {
Serializable originalId = (Serializable) entityInfo.getProjection()[0];
Object original = entityProvider.get( indexClass, originalId );
if ( original != null ) {
this.update( original, tx );
}
else {
// original is not available in the
// database, but it will be deleted by its
// own delete event
// TODO: log this?
}
}
processed += HSQUERY_BATCH;
}
}
}
}
}
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:77,代码来源:IndexUpdater.java
注:本文中的org.hibernate.search.bridge.StringBridge类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论