Package org.hibernate.annotationfactory

Examples of org.hibernate.annotationfactory.AnnotationDescriptor


    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

          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) {
    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 ) );
        overrides.add( (AssociationOverride) AnnotationFactory.create( override ) );
      }
    }
    return overrides;
  }
View Full Code Here

        element.elements( isInverse ? "inverse-join-column" : "join-column" ) :
        null;
    List<JoinColumn> joinColumns = new ArrayList<JoinColumn>();
    if ( subelements != null ) {
      for ( Element subelement : subelements ) {
        AnnotationDescriptor column = new AnnotationDescriptor( JoinColumn.class );
        copyStringAttribute( column, subelement, "name", false );
        copyStringAttribute( column, subelement, "referenced-column-name", false );
        copyBooleanAttribute( column, subelement, "unique" );
        copyBooleanAttribute( column, subelement, "nullable" );
        copyBooleanAttribute( column, subelement, "insertable" );
View Full Code Here

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

  private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements) {
    List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
    if ( subelements != null && subelements.size() > 0 ) {
      for ( Element current : subelements ) {
        if ( ! current.getName().equals( "attribute-override" ) ) continue;
        AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
        copyStringAttribute( override, current, "name", true );
        Element column = current != null ? current.element( "column" ) : null;
        override.setValue( "column", getColumn( column, true, current ) );
        overrides.add( (AttributeOverride) AnnotationFactory.create( override ) );
      }
    }
    return overrides;
  }
View Full Code Here

  }

  private Column getColumn(Element element, boolean isMandatory, Element current) {
    //Element subelement = element != null ? element.element( "column" ) : null;
    if ( element != null ) {
      AnnotationDescriptor column = new AnnotationDescriptor( Column.class );
      copyStringAttribute( column, element, "name", false );
      copyBooleanAttribute( column, element, "unique" );
      copyBooleanAttribute( column, element, "nullable" );
      copyBooleanAttribute( column, element, "insertable" );
      copyBooleanAttribute( column, element, "updatable" );
View Full Code Here

    String access = tree == null ? null : tree.attributeValue( "access" );
    if ( "FIELD".equals( access ) || "PROPERTY".equals( access ) ) {
      access = access.toLowerCase();
    }
    if ( access != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( AccessType.class );
      ad.setValue( "value", access );
      return AnnotationFactory.create( ad );
    }
    else if ( defaults.canUseJavaAnnotations() && super.isAnnotationPresent( AccessType.class ) ) {
      AccessType annotation = super.getAnnotation( AccessType.class );
      return annotation;
    }
    else if ( defaults.getAccess() != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( AccessType.class );
      ad.setValue( "value", defaults.getAccess() );
      return AnnotationFactory.create( ad );
    }
    else {
      return null;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.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.