當前位置: 首頁>>代碼示例>>Java>>正文


Java HSQuery類代碼示例

本文整理匯總了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 );
}
 
開發者ID:Hotware,項目名稱:Hibernate-Search-GenericJPA,代碼行數:9,代碼來源:StandaloneSearchFactoryImpl.java

示例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 );
}
 
開發者ID:Hotware,項目名稱:Hibernate-Search-GenericJPA,代碼行數:4,代碼來源:DtoQueryExecutor.java

示例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;
}
 
開發者ID:Hotware,項目名稱:Hibernate-Search-GenericJPA,代碼行數:6,代碼來源:HSearchQueryImpl.java

示例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;
				}
			}
		}
	}
}
 
開發者ID:Hotware,項目名稱:Hibernate-Search-GenericJPA,代碼行數:77,代碼來源:IndexUpdater.java


注:本文中的org.hibernate.search.query.engine.spi.HSQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。