Package org.hibernate

Examples of org.hibernate.AnnotationException


      }
      else if ( "AUTO".equalsIgnoreCase( strategy ) ) {
        ad.setValue( "strategy", GenerationType.AUTO );
      }
      else if ( StringHelper.isNotEmpty( strategy ) ) {
        throw new AnnotationException( "Unknown GenerationType: " + strategy + ". " + SCHEMA_VALIDATION );
      }
      copyStringAttribute( ad, subElement, "generator", false );
      return AnnotationFactory.create( ad );
    }
    else {
View Full Code Here


      }
      else if ( "TIMESTAMP".equalsIgnoreCase( temporal ) ) {
        ad.setValue( "value", TemporalType.TIMESTAMP );
      }
      else if ( StringHelper.isNotEmpty( temporal ) ) {
        throw new AnnotationException( "Unknown TemporalType: " + temporal + ". " + SCHEMA_VALIDATION );
      }
      annotationList.add( AnnotationFactory.create( ad ) );
    }
  }
View Full Code Here

      AccessType type;
      try {
        type = AccessType.valueOf( access );
      }
      catch ( IllegalArgumentException e ) {
        throw new AnnotationException( access + " is not a valid access type. Check you xml confguration." );
      }

      if ( ( AccessType.PROPERTY.equals( type ) && this.element instanceof Method ) ||
          ( AccessType.FIELD.equals( type ) && this.element instanceof Field ) ) {
        return;
View Full Code Here

      copyIntegerAttribute( column, element, "scale" );
      return (Column) AnnotationFactory.create( column );
    }
    else {
      if ( isMandatory ) {
        throw new AnnotationException( current.getPath() + ".column is mandatory. " + SCHEMA_VALIDATION );
      }
      return null;
    }
  }
View Full Code Here

      AccessType type;
      try {
        type = AccessType.valueOf( access );
      }
      catch ( IllegalArgumentException e ) {
        throw new AnnotationException( access + " is not a valid access type. Check you xml confguration." );
      }
      ad.setValue( "value", type );
      return AnnotationFactory.create( ad );
    }
    else if ( defaults.canUseJavaAnnotations() && isJavaAnnotationPresent( Access.class ) ) {
View Full Code Here

      List<EntityResult> entityResults = new ArrayList<EntityResult>( elements.size() );
      for ( Element entityResult : elements ) {
        AnnotationDescriptor entityResultDescriptor = new AnnotationDescriptor( EntityResult.class );
        String clazzName = entityResult.attributeValue( "entity-class" );
        if ( clazzName == null ) {
          throw new AnnotationException( "<entity-result> without entity-class. " + SCHEMA_VALIDATION );
        }
        Class clazz;
        try {
          clazz = ReflectHelper.classForName(
              XMLContext.buildSafeClassName( clazzName, defaults ),
              JPAOverridenAnnotationReader.class
          );
        }
        catch ( ClassNotFoundException e ) {
          throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
        }
        entityResultDescriptor.setValue( "entityClass", clazz );
        copyStringAttribute( entityResultDescriptor, entityResult, "discriminator-column", false );
        List<FieldResult> fieldResults = new ArrayList<FieldResult>();
        for ( Element fieldResult : (List<Element>) entityResult.elements( "field-result" ) ) {
          AnnotationDescriptor fieldResultDescriptor = new AnnotationDescriptor( FieldResult.class );
          copyStringAttribute( fieldResultDescriptor, fieldResult, "name", true );
          copyStringAttribute( fieldResultDescriptor, fieldResult, "column", true );
          fieldResults.add( (FieldResult) AnnotationFactory.create( fieldResultDescriptor ) );
        }
        entityResultDescriptor.setValue(
            "fields", fieldResults.toArray( new FieldResult[fieldResults.size()] )
        );
        entityResults.add( (EntityResult) AnnotationFactory.create( entityResultDescriptor ) );
      }
      ann.setValue( "entities", entityResults.toArray( new EntityResult[entityResults.size()] ) );

      elements = subelement.elements( "column-result" );
      List<ColumnResult> columnResults = new ArrayList<ColumnResult>( elements.size() );
      for ( Element columnResult : elements ) {
        AnnotationDescriptor columnResultDescriptor = new AnnotationDescriptor( ColumnResult.class );
        copyStringAttribute( columnResultDescriptor, columnResult, "name", true );
        columnResults.add( (ColumnResult) AnnotationFactory.create( columnResultDescriptor ) );
      }
      ann.setValue( "columns", columnResults.toArray( new ColumnResult[columnResults.size()] ) );
      //FIXME there is never such a result-class, get rid of it?
      String clazzName = subelement.attributeValue( "result-class" );
      if ( StringHelper.isNotEmpty( clazzName ) ) {
        Class clazz;
        try {
          clazz = ReflectHelper.classForName(
              XMLContext.buildSafeClassName( clazzName, defaults ),
              JPAOverridenAnnotationReader.class
          );
        }
        catch ( ClassNotFoundException e ) {
          throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
        }
        ann.setValue( "resultClass", clazz );
      }
      copyStringAttribute( ann, subelement, "result-set-mapping", false );
      resultsets.add( (SqlResultSetMapping) AnnotationFactory.create( ann ) );
View Full Code Here

          isNative ? NamedNativeQuery.class : NamedQuery.class
      );
      copyStringAttribute( ann, subelement, "name", false );
      Element queryElt = subelement.element( "query" );
      if ( queryElt == null ) {
        throw new AnnotationException( "No <query> element found." + SCHEMA_VALIDATION );
      }
      copyStringElement( queryElt, ann, "query" );
      List<Element> elements = subelement.elements( "hint" );
      List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
      for ( Element hint : elements ) {
        AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
        String value = hint.attributeValue( "name" );
        if ( value == null ) {
          throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
        }
        hintDescriptor.setValue( "name", value );
        value = hint.attributeValue( "value" );
        if ( value == null ) {
          throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION );
        }
        hintDescriptor.setValue( "value", value );
        queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
      }
      ann.setValue( "hints", queryHints.toArray( new QueryHint[queryHints.size()] ) );
      String clazzName = subelement.attributeValue( "result-class" );
      if ( StringHelper.isNotEmpty( clazzName ) ) {
        Class clazz;
        try {
          clazz = ReflectHelper.classForName(
              XMLContext.buildSafeClassName( clazzName, defaults ),
              JPAOverridenAnnotationReader.class
          );
        }
        catch ( ClassNotFoundException e ) {
          throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
        }
        ann.setValue( "resultClass", clazz );
      }
      copyStringAttribute( ann, subelement, "result-set-mapping", false );
      namedQueries.add( AnnotationFactory.create( ann ) );
View Full Code Here

        }
        else if ( "INTEGER".equals( value ) ) {
          type = DiscriminatorType.INTEGER;
        }
        else {
          throw new AnnotationException(
              "Unknown DiscrimiatorType in XML: " + value + " (" + SCHEMA_VALIDATION + ")"
          );
        }
      }
      ad.setValue( "discriminatorType", type );
View Full Code Here

        }
        else if ( "TABLE_PER_CLASS".equals( value ) ) {
          strategy = InheritanceType.TABLE_PER_CLASS;
        }
        else {
          throw new AnnotationException(
              "Unknown InheritanceType in XML: " + value + " (" + SCHEMA_VALIDATION + ")"
          );
        }
      }
      ad.setValue( "strategy", strategy );
View Full Code Here

              XMLContext.buildSafeClassName( attr.getValue(), defaults ),
              this.getClass()
          );
        }
        catch ( ClassNotFoundException e ) {
          throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e );
        }
        ad.setValue( "value", clazz );
        return AnnotationFactory.create( ad );
      }
      else {
        throw new AnnotationException( "id-class without class. " + SCHEMA_VALIDATION );
      }
    }
    else if ( defaults.canUseJavaAnnotations() ) {
      return getJavaAnnotation( IdClass.class );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.AnnotationException

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.