Package org.hibernate.annotations.common.reflection

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


      String[] columnsNames = new String[columns.size()];
      for ( int i = 0; i < columns.size(); i++ ) {
        columnsNames[i] = ( (Column) columns.get( i ) ).getName();
      }

      final XProperty xProperty = (XProperty) typeParameters.get( DynamicParameterizedType.XPROPERTY );
      // todo : not sure this works for handling @MapKeyEnumerated
      final Annotation[] annotations = xProperty == null
          ? null
          : xProperty.getAnnotations();

      typeParameters.put(
          DynamicParameterizedType.PARAMETER_TYPE,
          new ParameterTypeImpl(
              ReflectHelper.classForName(
View Full Code Here


          "@IdClass class should not have @Id nor @EmbeddedId properties: "
              + BinderHelper.getPath( propertyHolder, inferredData )
      );
    }
    XClass returnedClass = inferredData.getClassOrElement();
    XProperty property = inferredData.getProperty();
    //clone classGenerator and override with local values
    HashMap<String, IdGenerator> localGenerators = ( HashMap<String, IdGenerator> ) classGenerators.clone();
    localGenerators.putAll( buildLocalGenerators( property, mappings ) );

    //manage composite related metadata
    //guess if its a component and find id data access (property, field etc)
    final boolean isComponent = returnedClass.isAnnotationPresent( Embeddable.class )
        || property.isAnnotationPresent( EmbeddedId.class );

    GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
    String generatorType = generatedValue != null ?
        generatorType( generatedValue.strategy(), mappings ) :
        "assigned";
    String generatorName = generatedValue != null ?
        generatedValue.generator() :
View Full Code Here

                + " has no persistent id property: "
                + BinderHelper.getPath( propertyHolder, inferredData )
        );
      }
    }
    XProperty property = inferredData.getProperty();
    setupComponentTuplizer( property, comp );
    PropertyBinder binder = new PropertyBinder();
    binder.setName( inferredData.getPropertyName() );
    binder.setValue( comp );
    binder.setProperty( inferredData.getProperty() );
View Full Code Here

          propertyAnnotatedElement,
          new HashMap<String, IdGenerator>(), entityBinder, isIdentifierMapper, isComponentEmbedded,
          inSecondPass, mappings, inheritanceStatePerClass
      );

      XProperty property = propertyAnnotatedElement.getProperty();
      if ( property.isAnnotationPresent( GeneratedValue.class ) &&
          property.isAnnotationPresent( Id.class ) ) {
        //clone classGenerator and override with local values
        Map<String, IdGenerator> localGenerators = new HashMap<String, IdGenerator>();
        localGenerators.putAll( buildLocalGenerators( property, mappings ) );

        GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
        String generatorType = generatedValue != null ? generatorType(
            generatedValue.strategy(), mappings
        ) : "assigned";
        String generator = generatedValue != null ? generatedValue.generator() : BinderHelper.ANNOTATION_STRING_DEFAULT;

        BinderHelper.makeIdGenerator(
            ( SimpleValue ) comp.getProperty( property.getName() ).getValue(),
            generatorType,
            generator,
            mappings,
            localGenerators
        );
View Full Code Here

      }
      if ( componentId.getPropertySpan() == 0 ) {
        throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
      }
      //tuplizers
      XProperty property = inferredData.getProperty();
      setupComponentTuplizer( property, componentId );
    }
    else {
      //TODO I think this branch is never used. Remove.
View Full Code Here

    // This is a @OneToOne mapped to a physical o.h.mapping.ManyToOne
    if ( unique ) {
      value.markAsLogicalOneToOne();
    }
    value.setReferencedEntityName( ToOneBinder.getReferenceEntityName( inferredData, targetEntity, mappings ) );
    final XProperty property = inferredData.getProperty();
    defineFetchingStrategy( value, property );
    //value.setFetchMode( fetchMode );
    value.setIgnoreNotFound( ignoreNotFound );
    value.setCascadeDeleteEnabled( cascadeOnDelete );
    //value.setLazy( fetchMode != FetchMode.JOIN );
    if ( !optional ) {
      for ( Ejb3JoinColumn column : columns ) {
        column.setNullable( false );
      }
    }
    if ( property.isAnnotationPresent( MapsId.class ) ) {
      //read only
      for ( Ejb3JoinColumn column : columns ) {
        column.setInsertable( false );
        column.setUpdatable( false );
      }
    }
   
    final JoinColumn joinColumn = property.getAnnotation( JoinColumn.class );

    //Make sure that JPA1 key-many-to-one columns are read only tooj
    boolean hasSpecjManyToOne=false;
    if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
      String columnName = "";
      for ( XProperty prop : inferredData.getDeclaringClass()
          .getDeclaredProperties( AccessType.FIELD.getType() ) ) {
        if ( prop.isAnnotationPresent( Id.class ) && prop.isAnnotationPresent( Column.class ) ) {
          columnName = prop.getAnnotation( Column.class ).name();
        }

        if ( property.isAnnotationPresent( ManyToOne.class ) && joinColumn != null
            && ! BinderHelper.isEmptyAnnotationValue( joinColumn.name() )
            && joinColumn.name().equals( columnName )
            && !property.isAnnotationPresent( MapsId.class ) ) {
           hasSpecjManyToOne = true;
          for ( Ejb3JoinColumn column : columns ) {
            column.setInsertable( false );
            column.setUpdatable( false );
          }
        }
      }

    }
    value.setTypeName( inferredData.getClassOrElementName() );
    final String propertyName = inferredData.getPropertyName();
    value.setTypeUsingReflection( propertyHolder.getClassName(), propertyName );
   
    String fkName = null;
    if ( joinColumn != null && joinColumn.foreignKey() != null ) {
      fkName = joinColumn.foreignKey().name();
    }
    if ( StringHelper.isEmpty( fkName ) ) {
      ForeignKey fk = property.getAnnotation( ForeignKey.class );
      fkName = fk != null ? fk.name() : "";
    }
    if ( !StringHelper.isEmpty( fkName ) ) {
      value.setForeignKeyName( fkName );
    }
View Full Code Here

      return targetEntity.getName();
    }
  }

  public static XClass getTargetEntity(PropertyData propertyData, Mappings mappings) {
    XProperty property = propertyData.getProperty();
    return mappings.getReflectionManager().toXClass( getTargetEntityClass( property ) );
  }
View Full Code Here

  }

  //must only be called after all setters are defined and before bind
  private void extractDataFromPropertyData(PropertyData inferredData) {
    if ( inferredData != null ) {
      XProperty property = inferredData.getProperty();
      if ( property != null ) {
        processExpression( property.getAnnotation( ColumnTransformer.class ) );
        ColumnTransformers annotations = property.getAnnotation( ColumnTransformers.class );
        if (annotations != null) {
          for ( ColumnTransformer annotation : annotations.value() ) {
            processExpression( annotation );
          }
        }
View Full Code Here

      String path,
      PropertyData inferredData,
      PropertyHolder parent,
      Mappings mappings) {
    super( path, parent, inferredData.getPropertyClass(), mappings );
    final XProperty embeddedXProperty = inferredData.getProperty();
    setCurrentProperty( embeddedXProperty );
    this.component = component;
    this.isOrWithinEmbeddedId =
        parent.isOrWithinEmbeddedId()
            || ( embeddedXProperty != null &&
            ( embeddedXProperty.isAnnotationPresent( Id.class )
                || embeddedXProperty.isAnnotationPresent( EmbeddedId.class ) ) );

    this.virtual = embeddedXProperty == null;
    if ( !virtual ) {
      this.embeddedAttributeName = embeddedXProperty.getName();
      this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty );
    }
    else {
      embeddedAttributeName = "";
      this.attributeConversionInfoMap = Collections.emptyMap();
View Full Code Here

      }
      final XClass associatedClassWithIdClass = state.getClassWithIdClass( true );
      if ( associatedClassWithIdClass == null ) {
        //we cannot know for sure here unless we try and find the @EmbeddedId
        //Let's not do this thorough checking but do some extra validation
        final XProperty property = idPropertyOnBaseClass.getProperty();
        return property.isAnnotationPresent( ManyToOne.class )
            || property.isAnnotationPresent( OneToOne.class );

      }
      else {
        final XClass idClass = mappings.getReflectionManager().toXClass(
            associatedClassWithIdClass.getAnnotation( IdClass.class ).value()
View Full Code Here

TOP

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

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.