Package org.hibernate.annotations.common.annotationfactory

Examples of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor


  }

  private void getEnumerated(List<Annotation> annotationList, Element element) {
    Element subElement = element != null ? element.element( "enumerated" ) : null;
    if ( subElement != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( Enumerated.class );
      String enumerated = subElement.getTextTrim();
      if ( "ORDINAL".equalsIgnoreCase( enumerated ) ) {
        ad.setValue( "value", EnumType.ORDINAL );
      }
      else if ( "STRING".equalsIgnoreCase( enumerated ) ) {
        ad.setValue( "value", EnumType.STRING );
      }
      else if ( StringHelper.isNotEmpty( enumerated ) ) {
        throw new AnnotationException( "Unknown EnumType: " + enumerated + ". " + SCHEMA_VALIDATION );
      }
      annotationList.add( AnnotationFactory.create( ad ) );
View Full Code Here


  }

  private void getLob(List<Annotation> annotationList, Element element) {
    Element subElement = element != null ? element.element( "lob" ) : null;
    if ( subElement != null ) {
      annotationList.add( AnnotationFactory.create( new AnnotationDescriptor( Lob.class ) ) );
    }
  }
View Full Code Here

        if ( isProcessingId( defaults ) ) {
          Annotation annotation = getAttributeOverrides( element, defaults, false );
          addIfNotNull( annotationList, annotation );
          annotation = getAssociationOverrides( element, defaults, false );
          addIfNotNull( annotationList, annotation );
          AnnotationDescriptor ad = new AnnotationDescriptor( EmbeddedId.class );
          annotationList.add( AnnotationFactory.create( ad ) );
          getAccessType( annotationList, element );
        }
      }
    }
View Full Code Here

          //FIXME: fix the priority of xml over java for generator names
          annotation = getTableGenerator( element, defaults );
          addIfNotNull( annotationList, annotation );
          annotation = getSequenceGenerator( element, defaults );
          addIfNotNull( annotationList, annotation );
          AnnotationDescriptor id = new AnnotationDescriptor( Id.class );
          annotationList.add( AnnotationFactory.create( id ) );
          getAccessType( annotationList, element );
        }
      }
    }
View Full Code Here

    List<Column> columns = new ArrayList<Column>( subelements.size() );
    for ( Element subelement : subelements ) {
      columns.add( getColumn( subelement, false, element ) );
    }
    if ( columns.size() > 0 ) {
      AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
      columnsDescr.setValue( "columns", columns.toArray( new Column[columns.size()] ) );
      return AnnotationFactory.create( columnsDescr );
    }
    else {
      return null;
    }
View Full Code Here

  }

  private GeneratedValue buildGeneratedValue(Element element) {
    Element subElement = element != null ? element.element( "generated-value" ) : null;
    if ( subElement != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( GeneratedValue.class );
      String strategy = subElement.attributeValue( "strategy" );
      if ( "TABLE".equalsIgnoreCase( strategy ) ) {
        ad.setValue( "strategy", GenerationType.TABLE );
      }
      else if ( "SEQUENCE".equalsIgnoreCase( strategy ) ) {
        ad.setValue( "strategy", GenerationType.SEQUENCE );
      }
      else if ( "IDENTITY".equalsIgnoreCase( strategy ) ) {
        ad.setValue( "strategy", GenerationType.IDENTITY );
      }
      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 );
View Full Code Here

  }

  private void getTemporal(List<Annotation> annotationList, Element element) {
    Element subElement = element != null ? element.element( "temporal" ) : null;
    if ( subElement != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( Temporal.class );
      String temporal = subElement.getTextTrim();
      if ( "DATE".equalsIgnoreCase( temporal ) ) {
        ad.setValue( "value", TemporalType.DATE );
      }
      else if ( "TIME".equalsIgnoreCase( temporal ) ) {
        ad.setValue( "value", TemporalType.TIME );
      }
      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

    if ( element == null ) {
      return;
    }
    String access = element.attributeValue( "access" );
    if ( access != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( Access.class );
      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;
      }

      ad.setValue( "value", type );
      annotationList.add( AnnotationFactory.create( ad ) );
    }
  }
View Full Code Here

          addAssociationOverrideIfNeeded( current, attributes );
        }
      }
    }
    if ( attributes.size() > 0 ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( AssociationOverrides.class );
      ad.setValue( "value", attributes.toArray( new AssociationOverride[attributes.size()] ) );
      return AnnotationFactory.create( ad );
    }
    else {
      return null;
    }
View Full Code Here

  private List<AssociationOverride> buildAssociationOverrides(Element element, XMLContext.Default defaults) {
    List<Element> subelements = element == null ? null : element.elements( "association-override" );
    List<AssociationOverride> overrides = new ArrayList<AssociationOverride>();
    if ( subelements != null && subelements.size() > 0 ) {
      for ( Element current : subelements ) {
        AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class );
        copyStringAttribute( override, current, "name", true );
        override.setValue( "joinColumns", getJoinColumns( current, false ) );
        JoinTable joinTable = buildJoinTable( current, defaults );
        if ( joinTable != null ) {
          override.setValue( "joinTable", joinTable );
        }
        overrides.add( (AssociationOverride) AnnotationFactory.create( override ) );
      }
    }
    return overrides;
View Full Code Here

TOP

Related Classes of org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor

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.