Package org.hibernate.search

Examples of org.hibernate.search.SearchException


    NumericField numericFieldAnn = member.getAnnotation( NumericField.class );
    if ( idAnnotation != null ) {
      String attributeName = getIdAttributeName( member, idAnnotation );
      if ( isRoot ) {
        if ( explicitDocumentId ) {
          throw new SearchException( "More than one @DocumentId specified on entity " + getBeanClass().getName() );
        }
        if ( idAnnotation instanceof DocumentId ) {
          explicitDocumentId = true;
        }
        idKeywordName = prefix + attributeName;

        FieldBridge fieldBridge = BridgeFactory.guessType( null, numericFieldAnn, member, reflectionManager );
        if ( fieldBridge instanceof TwoWayFieldBridge ) {
          idBridge = (TwoWayFieldBridge) fieldBridge;
        }
        else {
          throw new SearchException(
              "Bridge for document id does not implement TwoWayFieldBridge: " + member.getName()
          );
        }
        idBoost = getBoost( member, null );
        ReflectionHelper.setAccessible( member );
View Full Code Here


    BuildContext buildContext = new BuildContext();

    final SearchMapping mapping = SearchMappingBuilder.getSearchMapping( cfg );
    if ( mapping != null ) {
      if ( !( reflectionManager instanceof MetadataProviderInjector ) ) {
        throw new SearchException(
            "Programmatic mapping model used but ReflectionManager does not implement "
                + MetadataProviderInjector.class.getName()
        );
      }
      MetadataProviderInjector injector = (MetadataProviderInjector) reflectionManager;
View Full Code Here

      for ( Class<?> indexedType : directoryConfiguration.getClasses() ) {
        DocumentBuilderIndexedEntity<?> documentBuilder = documentBuildersIndexedEntities.get( indexedType );
        Similarity similarity = documentBuilder.getSimilarity();
        Similarity prevSimilarity = directoryConfiguration.getSimilarity();
        if ( prevSimilarity != null && !prevSimilarity.getClass().equals( similarity.getClass() ) ) {
          throw new SearchException(
              "Multiple entities are sharing the same index but are declaring an " +
                  "inconsistent Similarity. When overrriding default Similarity make sure that all types sharing a same index " +
                  "declare the same Similarity implementation."
          );
        }
View Full Code Here

            org.hibernate.annotations.common.util.ReflectHelper
                .classForName( "javax.persistence.Id", ConfigContext.class );
        jpaId = member.getAnnotation( jpaIdClass );
      }
      catch ( ClassNotFoundException e ) {
        throw new SearchException( "Unable to load @Id.class even though it should be present ?!" );
      }
      if ( jpaId != null ) {
        log.debug( "Found JPA id and using it as document id" );
        idAnnotation = jpaId;
      }
View Full Code Here

    }
  }

  private void bindFilterDef(FullTextFilterDef defAnn, XClass mappedXClass) {
    if ( factoryState.getFilterDefinitions().containsKey( defAnn.name() ) ) {
      throw new SearchException(
          "Multiple definition of @FullTextFilterDef.name=" + defAnn.name() + ": "
              + mappedXClass.getName()
      );
    }
View Full Code Here

    }
    try {
      filterDef.getImpl().newInstance();
    }
    catch ( IllegalAccessException e ) {
      throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
    }
    catch ( InstantiationException e ) {
      throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
    }
    for ( Method method : filterDef.getImpl().getMethods() ) {
      if ( method.isAnnotationPresent( Factory.class ) ) {
        if ( filterDef.getFactoryMethod() != null ) {
          throw new SearchException(
              "Multiple @Factory methods found" + defAnn.name() + ": "
                  + filterDef.getImpl().getName() + "." + method.getName()
          );
        }
        ReflectionHelper.setAccessible( method );
        filterDef.setFactoryMethod( method );
      }
      if ( method.isAnnotationPresent( Key.class ) ) {
        if ( filterDef.getKeyMethod() != null ) {
          throw new SearchException(
              "Multiple @Key methods found" + defAnn.name() + ": "
                  + filterDef.getImpl().getName() + "." + method.getName()
          );
        }
        ReflectionHelper.setAccessible( method );
View Full Code Here

          return objectToString( (TwoWayFieldBridge) bridge, fieldName, value );
        }
        else if ( StringBridge.class.isAssignableFrom( bridgeClass ) ) {
          return objectToString( (StringBridge) bridge, fieldName, value );
        }
        throw new SearchException(
            "FieldBridge " + bridgeClass + "does not have a objectToString method: field "
                + fieldName + " in " + getBeanXClass()
        );
      }
    }
    throw new SearchException( "Unable to find field " + fieldName + " in " + getBeanXClass() );
  }
View Full Code Here

    FullTextFilterDef[] filterDefs = (FullTextFilterDef[]) defaults.get( FullTextFilterDefs.class );
    if ( filterDefs != null && filterDefs.length != 0 ) {
      final Map<String, FilterDef> filterDefinitions = factoryState.getFilterDefinitions();
      for ( FullTextFilterDef defAnn : filterDefs ) {
        if ( filterDefinitions.containsKey( defAnn.name() ) ) {
          throw new SearchException( "Multiple definition of @FullTextFilterDef.name=" + defAnn.name() );
        }
        bindFullTextFilterDef( defAnn );
      }
    }
  }
View Full Code Here

  }

  private static String defineIndexingStrategy(SearchConfiguration cfg) {
    String indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
    if ( !( "event".equals( indexingStrategy ) || "manual".equals( indexingStrategy ) ) ) {
      throw new SearchException( Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy );
    }
    return indexingStrategy;
  }
View Full Code Here

    }

    public Similarity getSimilarity(DirectoryProvider<?> provider) {
      Similarity similarity = factoryState.getDirectoryProviderData().get( provider ).getSimilarity();
      if ( similarity == null ) {
        throw new SearchException( "Assertion error: a similarity should be defined for each provider" );
      }
      return similarity;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.search.SearchException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.