本文整理匯總了Java中org.hibernate.search.query.engine.spi.HSQuery類的典型用法代碼示例。如果您正苦於以下問題:Java HSQuery類的具體用法?Java HSQuery怎麽用?Java HSQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HSQuery類屬於org.hibernate.search.query.engine.spi包,在下文中一共展示了HSQuery類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createQuery
import org.hibernate.search.query.engine.spi.HSQuery; //導入依賴的package包/類
@Override
public HSearchQuery createQuery(Query query, Class<?>... targetedEntities) {
HSQuery hsQuery = this.searchIntegrator.createHSQuery();
hsQuery.luceneQuery( query );
// to make sure no entity is used twice
hsQuery.targetedEntities( new ArrayList<>( new HashSet<>( Arrays.asList( targetedEntities ) ) ) );
return new HSearchQueryImpl( hsQuery, this.queryExec, this.searchIntegrator );
}
示例2: executeHSQuery
import org.hibernate.search.query.engine.spi.HSQuery; //導入依賴的package包/類
public <T> List<T> executeHSQuery(HSQuery hsQuery, Class<T> clazz) {
return this.executeHSQuery( hsQuery, clazz, DtoDescriptor.DtoDescription.DEFAULT_PROFILE );
}
示例3: HSearchQueryImpl
import org.hibernate.search.query.engine.spi.HSQuery; //導入依賴的package包/類
public HSearchQueryImpl(HSQuery hsquery, DtoQueryExecutor queryExec, SearchIntegrator searchIntegrator) {
this.hsquery = hsquery;
this.queryExec = queryExec;
this.searchIntegrator = searchIntegrator;
}
示例4: delete
import org.hibernate.search.query.engine.spi.HSQuery; //導入依賴的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;
}
}
}
}
}