Package org.hibernate.annotations.common.reflection

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


    if ( !mustBeSkipped( propertyAnnotatedElement.getProperty(), mappings ) ) {
      /*
       * put element annotated by @Id in front
       * since it has to be parsed before any assoctation by Hibernate
       */
      final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
      if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
        annElts.add( 0, propertyAnnotatedElement );
        hasIdentifier = true;
      }
      else {
        annElts.add( propertyAnnotatedElement );
View Full Code Here


    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( !prop.isAnnotationPresent( MapsId.class ) ) {
              /**
               * The detection of a configured individual JoinColumn differs between Annotation
               * and XML configuration processing.
               */
              boolean isRequiredAnnotationPresent = false;
              JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
              if ( (prop.isAnnotationPresent( JoinColumn.class )
                  && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
                isRequiredAnnotationPresent = true;
              }
              else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
                for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
                  if ( columnName.equals( columnAnnotation.name() ) ) {
                    isRequiredAnnotationPresent = true;
                    break;
                  }
                }
              }
              if ( isRequiredAnnotationPresent ) {
                //create a PropertyData fpr the specJ property holding the mapping
                PropertyData specJPropertyData = new PropertyInferredData(
                    declaringClass,
                    //same dec
                    prop,
                    // the actual @XToOne property
                    propertyAccessor,
                    //TODO we should get the right accessor but the same as id would do
                    mappings.getReflectionManager()
                );
                mappings.addPropertyAnnotatedWithMapsIdSpecj(
                    entity,
                    specJPropertyData,
                    element.toString()
                );
              }
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

  private boolean hasParents = false;
  private InheritanceType type;
  private boolean isEmbeddableSuperclass = false;

  private void extractInheritanceType() {
    XAnnotatedElement element = getClazz();
    Inheritance inhAnn = element.getAnnotation( Inheritance.class );
    MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
    if ( mappedSuperClass != null ) {
      setEmbeddableSuperclass( true );
      setType( inhAnn == null ? null : inhAnn.strategy() );
    }
    else {
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      hasIdentifier = true;
    }
    else {
      annElts.add( propertyAnnotatedElement );
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( prop.isAnnotationPresent( JoinColumn.class )
                && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )
                && !prop.isAnnotationPresent( MapsId.class ) ) {
              //create a PropertyData fpr the specJ property holding the mapping
              PropertyData specJPropertyData = new PropertyInferredData(
                  declaringClass,  //same dec
                  prop, // the actual @XToOne property
                  propertyAccessor, //TODO we should get the right accessor but the same as id would do
                  mappings.getReflectionManager()
              );
              mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() );
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( !prop.isAnnotationPresent( MapsId.class ) ) {
              /**
               * The detection of a configured individual JoinColumn differs between Annotation
               * and XML configuration processing.
               */
              boolean isRequiredAnnotationPresent = false;
              JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
              if ( (prop.isAnnotationPresent( JoinColumn.class )
                  && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
                isRequiredAnnotationPresent = true;
              }
              else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
                for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
                  if ( columnName.equals( columnAnnotation.name() ) ) {
                    isRequiredAnnotationPresent = true;
                    break;
                  }
                }
              }
              if ( isRequiredAnnotationPresent ) {
                //create a PropertyData fpr the specJ property holding the mapping
                PropertyData specJPropertyData = new PropertyInferredData(
                    declaringClass,
                    //same dec
                    prop,
                    // the actual @XToOne property
                    propertyAccessor,
                    //TODO we should get the right accessor but the same as id would do
                    mappings.getReflectionManager()
                );
                mappings.addPropertyAnnotatedWithMapsIdSpecj(
                    entity,
                    specJPropertyData,
                    element.toString()
                );
              }
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( !prop.isAnnotationPresent( MapsId.class ) ) {
              /**
               * The detection of a configured individual JoinColumn differs between Annotation
               * and XML configuration processing.
               */
              boolean isRequiredAnnotationPresent = false;
              JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
              if ( (prop.isAnnotationPresent( JoinColumn.class )
                  && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
                isRequiredAnnotationPresent = true;
              }
              else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
                for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
                  if ( columnName.equals( columnAnnotation.name() ) ) {
                    isRequiredAnnotationPresent = true;
                    break;
                  }
                }
              }
              if ( isRequiredAnnotationPresent ) {
                //create a PropertyData fpr the specJ property holding the mapping
                PropertyData specJPropertyData = new PropertyInferredData(
                    declaringClass,
                    //same dec
                    prop,
                    // the actual @XToOne property
                    propertyAccessor,
                    //TODO we should get the right accessor but the same as id would do
                    mappings.getReflectionManager()
                );
                mappings.addPropertyAnnotatedWithMapsIdSpecj(
                    entity,
                    specJPropertyData,
                    element.toString()
                );
              }
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( !prop.isAnnotationPresent( MapsId.class ) ) {
              /**
               * The detection of a configured individual JoinColumn differs between Annotation
               * and XML configuration processing.
               */
              boolean isRequiredAnnotationPresent = false;
              JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
              if ( (prop.isAnnotationPresent( JoinColumn.class )
                  && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
                isRequiredAnnotationPresent = true;
              }
              else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
                for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
                  if ( columnName.equals( columnAnnotation.name() ) ) {
                    isRequiredAnnotationPresent = true;
                    break;
                  }
                }
              }
              if ( isRequiredAnnotationPresent ) {
                //create a PropertyData fpr the specJ property holding the mapping
                PropertyData specJPropertyData = new PropertyInferredData(
                    declaringClass,
                    //same dec
                    prop,
                    // the actual @XToOne property
                    propertyAccessor,
                    //TODO we should get the right accessor but the same as id would do
                    mappings.getReflectionManager()
                );
                mappings.addPropertyAnnotatedWithMapsIdSpecj(
                    entity,
                    specJPropertyData,
                    element.toString()
                );
              }
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( !prop.isAnnotationPresent( MapsId.class ) ) {
              /**
               * The detection of a configured individual JoinColumn differs between Annotation
               * and XML configuration processing.
               */
              boolean isRequiredAnnotationPresent = false;
              JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
              if ( (prop.isAnnotationPresent( JoinColumn.class )
                  && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
                isRequiredAnnotationPresent = true;
              }
              else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
                for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
                  if ( columnName.equals( columnAnnotation.name() ) ) {
                    isRequiredAnnotationPresent = true;
                    break;
                  }
                }
              }
              if ( isRequiredAnnotationPresent ) {
                //create a PropertyData fpr the specJ property holding the mapping
                PropertyData specJPropertyData = new PropertyInferredData(
                    declaringClass,
                    //same dec
                    prop,
                    // the actual @XToOne property
                    propertyAccessor,
                    //TODO we should get the right accessor but the same as id would do
                    mappings.getReflectionManager()
                );
                mappings.addPropertyAnnotatedWithMapsIdSpecj(
                    entity,
                    specJPropertyData,
                    element.toString()
                );
              }
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

    /*
     * put element annotated by @Id in front
     * since it has to be parsed before any association by Hibernate
     */
    final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
    if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
      annElts.add( 0, propertyAnnotatedElement );
      /**
       * The property must be put in hibernate.properties as it's a system wide property. Fixable?
       * TODO support true/false/default on the property instead of present / not present
       * TODO is @Column mandatory?
       * TODO add method support
       */
      if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
        if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
          String columnName = element.getAnnotation( Column.class ).name();
          for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
            if ( prop.isAnnotationPresent( JoinColumn.class )
                && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )
                && !prop.isAnnotationPresent( MapsId.class ) ) {
              //create a PropertyData fpr the specJ property holding the mapping
              PropertyData specJPropertyData = new PropertyInferredData(
                  declaringClass,  //same dec
                  prop, // the actual @XToOne property
                  propertyAccessor, //TODO we should get the right accessor but the same as id would do
                  mappings.getReflectionManager()
              );
              mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() );
            }
          }
        }
      }

      if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
        mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
      }
      idPropertyCounter++;
    }
    else {
      annElts.add( propertyAnnotatedElement );
    }
    if ( element.isAnnotationPresent( MapsId.class ) ) {
      mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
    }

    return idPropertyCounter;
  }
View Full Code Here

TOP

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

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.