Package org.hibernate.annotations.common.reflection

Examples of org.hibernate.annotations.common.reflection.XClass


    for (XClass currClass = clazz; currClass != null; currClass = currClass.getSuperclass()) {
      hierarchy.add( currClass );
    }
    Class similarityClass = null;
    for (int index = hierarchy.size() - 1; index >= 0; index--) {
      XClass currClass = hierarchy.get( index );
      /**
       * Override the default analyzer for the properties if the class hold one
       * That's the reason we go down the hierarchy
       */
      Analyzer analyzer = getAnalyzer( currClass, context );

      if ( analyzer != null ) {
        propertiesMetadata.analyzer = analyzer;
      }
      checkForAnalyzerDefs( currClass, context );
      // Check for any ClassBridges annotation.
      ClassBridges classBridgesAnn = currClass.getAnnotation( ClassBridges.class );
      if ( classBridgesAnn != null ) {
        ClassBridge[] cbs = classBridgesAnn.value();
        for (ClassBridge cb : cbs) {
          bindClassAnnotation( prefix, propertiesMetadata, cb, context );
        }
      }

      // Check for any ClassBridge style of annotations.
      ClassBridge classBridgeAnn = currClass.getAnnotation( ClassBridge.class );
      if ( classBridgeAnn != null ) {
        bindClassAnnotation( prefix, propertiesMetadata, classBridgeAnn, context );
      }

      //Get similarity
      //TODO: similarity form @IndexedEmbedded are not taken care of. Exception??
      if ( isRoot ) {
        org.hibernate.search.annotations.Similarity similarityAnn = currClass.getAnnotation( org.hibernate.search.annotations.Similarity.class );
        if ( similarityAnn != null ) {
          if ( similarityClass != null ) {
            throw new SearchException( "Multiple Similarities defined in the same class hierarchy: " + beanClass.getName() );
          }
          similarityClass = similarityAnn.impl();
        }
      }

      //rejecting non properties (ie regular methods) because the object is loaded from Hibernate,
      // so indexing a non property does not make sense
      List<XProperty> methods = currClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
      for (XProperty method : methods) {
        initializeMember( method, propertiesMetadata, isRoot, prefix, processedClasses, context );
      }

      List<XProperty> fields = currClass.getDeclaredProperties( XClass.ACCESS_FIELD );
      for (XProperty field : fields) {
        initializeMember( field, propertiesMetadata, isRoot, prefix, processedClasses, context );
      }
    }
    if ( isRoot && similarityClass != null ) {
View Full Code Here


        potentialLevel = Integer.MAX_VALUE;
      }
      maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
      level++;

      XClass elementClass;
      if ( void.class == embeddedAnn.targetElement() ) {
        elementClass = member.getElementClass();
      }
      else {
        elementClass = reflectionManager.toXClass( embeddedAnn.targetElement() );
      }
      if ( maxLevel == Integer.MAX_VALUE //infinite
          && processedClasses.contains( elementClass ) ) {
        throw new SearchException(
            "Circular reference. Duplicate use of "
                + elementClass.getName()
                + " in root entity " + beanClass.getName()
                + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
        );
      }
      if ( level <= maxLevel ) {
View Full Code Here

    return idAnnotation;
  }

  private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
    ProvidedId id = null;
    XClass currentClass = clazz;
    while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
      id = currentClass.getAnnotation( ProvidedId.class );
      currentClass = currentClass.getSuperclass();
    }
    return id;
  }
View Full Code Here

  private void initializeClass(XClass clazz, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix,
                 Set<XClass> processedClasses, ConfigContext context, Set<XClass> optimizationBlackList,
                 boolean disableOptimizationsArg, PathsContext pathsContext) {
    List<XClass> hierarchy = new LinkedList<XClass>();
    XClass next;
    for ( XClass previousClass = clazz; previousClass != null; previousClass = next ) {
      next = previousClass.getSuperclass();
      if ( next != null ) {
        hierarchy.add( 0, previousClass ); // append to head to create a list in top-down iteration order
      }
View Full Code Here

      return EMPTY;
    }
  }

  private void updateContainedInMaxDepth(XMember memberWithContainedIn, PropertiesMetadata propertiesMetadata, String accessType) {
    XClass memberReturnedType = memberWithContainedIn.getElementClass();
    String mappedBy = mappedBy( memberWithContainedIn );
    List<XProperty> returnedTypeProperties = memberReturnedType.getDeclaredProperties( accessType );
    for ( XProperty property : returnedTypeProperties ) {
      if ( isCorrespondingIndexedEmbedded( mappedBy, property ) ) {
          updateDepthProperties( memberWithContainedIn, propertiesMetadata, memberReturnedType, property );
          break;
        }
View Full Code Here

        potentialLevel = Integer.MAX_VALUE;
      }
      maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
      level++;

      XClass elementClass;
      if ( void.class == embeddedAnn.targetElement() ) {
        elementClass = member.getElementClass();
      }
      else {
        elementClass = reflectionManager.toXClass( embeddedAnn.targetElement() );
      }

      if ( maxLevel == Integer.MAX_VALUE //infinite
          && processedClasses.contains( elementClass ) ) {
        throw new SearchException(
            "Circular reference. Duplicate use of "
                + elementClass.getName()
                + " in root entity " + beanXClass.getName()
                + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
        );
      }
View Full Code Here

      Spatial spatialAnn = member.getAnnotation( org.hibernate.search.annotations.Spatial.class );
      bridge = buildSpatialBridge( spatialAnn, member );
    }
    else {
      //find in built-ins
      XClass returnType = member.getType();
      bridge = builtInBridges.get( returnType.getName() );
      if ( bridge == null && returnType.isEnum() ) {
        //we return one enum type bridge instance per property as it is customized per ReturnType
        @SuppressWarnings("unchecked")
        final EnumBridge enumBridge = new EnumBridge();
        populateReturnType( reflectionManager.toClass( member.getType() ), EnumBridge.class, enumBridge );
        bridge = new TwoWayString2FieldBridgeAdaptor( enumBridge );
View Full Code Here

    else if ( numericField != null ) {
      bridge = numericBridges.get( member.getType().getName() );
    }
    else {
      //find in built-ins
      XClass returnType = member.getType();
      bridge = builtInBridges.get( returnType.getName() );
      if ( bridge == null && returnType.isEnum() ) {
        //we return one enum type bridge instance per property as it is customized per ReturnType
        @SuppressWarnings("unchecked")
        final EnumBridge enumBridge = new EnumBridge();
        populateReturnType( reflectionManager.toClass( member.getType() ), EnumBridge.class, enumBridge );
        bridge = new TwoWayString2FieldBridgeAdaptor( enumBridge );
View Full Code Here

    return idAnnotation;
  }

  private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
    ProvidedId id = null;
    XClass currentClass = clazz;
    while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
      id = currentClass.getAnnotation( ProvidedId.class );
      currentClass = currentClass.getSuperclass();
    }
    return id;
  }
View Full Code Here

    while ( iter.hasNext() ) {
      Class<?> mappedClass = iter.next();
      if ( mappedClass == null ) {
        continue;
      }
      @SuppressWarnings("unchecked")
      XClass mappedXClass = reflectionManager.toXClass( mappedClass );
      if ( mappedXClass == null ) {
        continue;
      }

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {

        if ( mappedXClass.isAbstract() ) {
          log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
          continue;
        }

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
View Full Code Here

TOP

Related Classes of org.hibernate.annotations.common.reflection.XClass

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.