Package org.hibernate.annotations.common.annotationfactory

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


  private void getJoinTable(List<Annotation> annotationList, Element tree, XMLContext.Default defaults) {
    Element subelement = tree == null ? null : tree.element( "join-table" );
    final Class<JoinTable> annotationType = JoinTable.class;
    if ( subelement != null ) {
      //ignore java annotation, an element is defined
      AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType );
      copyStringAttribute( annotation, subelement, "name", false );
      copyStringAttribute( annotation, subelement, "catalog", false );
      if ( StringHelper.isNotEmpty( defaults.getCatalog() )
          && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) {
        annotation.setValue( "catalog", defaults.getCatalog() );
      }
      copyStringAttribute( annotation, subelement, "schema", false );
      if ( StringHelper.isNotEmpty( defaults.getSchema() )
          && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) {
        annotation.setValue( "schema", defaults.getSchema() );
      }
      buildUniqueConstraints( annotation, subelement );
      annotation.setValue( "joinColumns", getJoinColumns( subelement, false ) );
      annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, true ) );
      annotationList.add( AnnotationFactory.create( annotation ) );
    }
  }
View Full Code Here


      Class<? extends Annotation> annotationType, List<Annotation> annotationList, XMLContext.Default defaults
  ) {
    String xmlName = annotationToXml.get( annotationType );
    for (Element element : elementsForProperty) {
      if ( xmlName.equals( element.getName() ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( annotationType );
        String className = element.attributeValue( "target-entity" );
        if ( className != null ) {
          Class clazz;
          try {
            clazz = ReflectHelper.classForName(
                XMLContext.buildSafeClassName( className, defaults ),
                this.getClass()
            );
          }
          catch (ClassNotFoundException e) {
            throw new AnnotationException(
                "Unable to find " + element.getPath() + "target-entity: " + className, e
            );
          }
          ad.setValue( "targetEntity", clazz );
        }
        getFetchType( ad, element );
        getCascades( ad, element, defaults );
        getJoinTable( annotationList, element, defaults );
        buildJoinColumns( annotationList, element, defaults );
View Full Code Here

  private void getOrderBy(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
    Element subelement = element != null ? element.element( "order-by" ) : null;
    if ( subelement != null ) {
      String orderByString = subelement.getTextTrim();
      AnnotationDescriptor ad = new AnnotationDescriptor( OrderBy.class );
      if ( StringHelper.isNotEmpty( orderByString ) ) ad.setValue( "value", orderByString );
      annotationList.add( AnnotationFactory.create( ad ) );
    }
  }
View Full Code Here

  private void getMapKey(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
    Element subelement = element != null ? element.element( "map-key" ) : null;
    if ( subelement != null ) {
      String mapKeyString = subelement.attributeValue( "name" );
      AnnotationDescriptor ad = new AnnotationDescriptor( MapKey.class );
      if ( StringHelper.isNotEmpty( mapKeyString ) ) ad.setValue( "name", mapKeyString );
      annotationList.add( AnnotationFactory.create( ad ) );
    }
  }
View Full Code Here

  }

  private void buildJoinColumns(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
    JoinColumn[] joinColumns = getJoinColumns( element, false );
    if ( joinColumns.length > 0 ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( JoinColumns.class );
      ad.setValue( "value", joinColumns );
      annotationList.add( AnnotationFactory.create( ad ) );
    }
  }
View Full Code Here

  }

  private void getEmbedded(List<Annotation> annotationList, XMLContext.Default defaults) {
    for (Element element : elementsForProperty) {
      if ( "embedded".equals( element.getName() ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( Embedded.class );
        annotationList.add( AnnotationFactory.create( ad ) );
      }
    }
    if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
      Annotation annotation = getJavaAnnotation( Embedded.class );
View Full Code Here

  }

  private Transient getTransient(XMLContext.Default defaults) {
    for (Element element : elementsForProperty) {
      if ( "transient".equals( element.getName() ) ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( Transient.class );
        return AnnotationFactory.create( ad );
      }
    }
    if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
      return getJavaAnnotation( Transient.class );
View Full Code Here

    for (Element element : elementsForProperty) {
      if ( "version".equals( element.getName() ) ) {
        Annotation annotation = buildColumns( element );
        addIfNotNull( annotationList, annotation );
        getTemporal( annotationList, element );
        AnnotationDescriptor basic = new AnnotationDescriptor( Version.class );
        annotationList.add( AnnotationFactory.create( basic ) );
      }
    }
    if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
      //we have nothing, so Java annotations might occurs
View Full Code Here

        Annotation annotation = buildColumns( element );
        addIfNotNull( annotationList, annotation );
        getTemporal( annotationList, element );
        getLob( annotationList, element );
        getEnumerated( annotationList, element );
        AnnotationDescriptor basic = new AnnotationDescriptor( Basic.class );
        getFetchType( basic, element );
        copyBooleanAttribute( basic, element, "optional" );
        annotationList.add( AnnotationFactory.create( basic ) );
      }
    }
View Full Code Here

  }

  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

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.