Package javax.persistence

Examples of javax.persistence.JoinColumn


      };
    }
    else {
      joinColumns = new Ejb3JoinColumn[annJoins.length];
      JoinColumn annJoin;
      int length = annJoins.length;
      for (int index = 0; index < length; index++) {
        annJoin = annJoins[index];
        Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();
        currentJoinColumn.setImplicit( true );
View Full Code Here


          .getDeclaredProperties( AccessType.FIELD.getType() ) ) {
        if ( prop.isAnnotationPresent( Id.class ) && prop.isAnnotationPresent( Column.class ) ) {
          columnName = prop.getAnnotation( Column.class ).name();
        }

        final JoinColumn joinColumn = property.getAnnotation( JoinColumn.class );
        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 );
View Full Code Here

          this.checkFetch(collection, manyToOne, beanDescriptor, propertyDescriptor, fetchType);

          if (!propertyDescriptor.isAnnotationPresent(JoinColumn.class)) {
            collection.add("Missing @JoinColumn on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
          } else {
            JoinColumn joinColumn = propertyDescriptor.getAnnotation(JoinColumn.class);
            if (manyToOne.optional() != joinColumn.nullable()) {
              collection.add("Conflict in @ManyToOne(optional) and @JoinColumn(nullable) on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
            }
          }
        }
        if (propertyDescriptor.isAnnotationPresent(OneToMany.class)) {
          OneToMany oneToMany = propertyDescriptor.getAnnotation(OneToMany.class);
          CascadeType[] cascades = oneToMany.cascade();
          FetchType fetchType = oneToMany.fetch();
          String mappedBy = oneToMany.mappedBy();

          this.checkCascade(collection, oneToMany, beanDescriptor, propertyDescriptor, cascades);
          this.checkFetch(collection, oneToMany, beanDescriptor, propertyDescriptor, fetchType);
          this.checkMappedBy(collection, oneToMany, beanDescriptor, propertyDescriptor, mappedBy);
        }
        if (propertyDescriptor.isAnnotationPresent(OneToOne.class)) {
          OneToOne oneToOne = propertyDescriptor.getAnnotation(OneToOne.class);
          CascadeType[] cascades = oneToOne.cascade();
          FetchType fetchType = oneToOne.fetch();
          String mappedBy = oneToOne.mappedBy();

          this.checkCascade(collection, oneToOne, beanDescriptor, propertyDescriptor, cascades);
          this.checkFetch(collection, oneToOne, beanDescriptor, propertyDescriptor, fetchType);

          if (ConditionUtils.isEmpty(mappedBy)) {
            if (!propertyDescriptor.isAnnotationPresent(JoinColumn.class)) {
              collection.add("Missing @OneToOne(mappedBy) or @JoinColumn on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
            } else {
              JoinColumn joinColumn = propertyDescriptor.getAnnotation(JoinColumn.class);
              if (oneToOne.optional() != joinColumn.nullable()) {
                collection.add("Conflict in @OneToOne(optional) and @JoinColumn(nullable) on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
              }
            }
          }
        }
View Full Code Here

      };
    }
    else {
      joinColumns = new Ejb3JoinColumn[annJoins.length];
      JoinColumn annJoin;
      int length = annJoins.length;
      for (int index = 0; index < length; index++) {
        annJoin = annJoins[index];
        Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();
        currentJoinColumn.setImplicit( true );
View Full Code Here

          .getDeclaredProperties( AccessType.FIELD.getType() ) ) {
        if ( prop.isAnnotationPresent( Id.class ) && prop.isAnnotationPresent( Column.class ) ) {
          columnName = prop.getAnnotation( Column.class ).name();
        }

        final JoinColumn joinColumn = property.getAnnotation( JoinColumn.class );
        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 );
View Full Code Here

  private class JPAEdmAssociationEndBuilder implements JPAEdmBuilder {

    @Override
    public void build() throws ODataJPAModelException {

      JoinColumn joinColumn = null;

      currentAssociationEnd1 = new AssociationEnd();
      currentAssociationEnd2 = new AssociationEnd();

      JPAEdmNameBuilder.build(JPAEdmAssociationEnd.this, entityTypeView, propertyView);

      currentAssociationEnd1.setRole(currentAssociationEnd1.getType().getName());
      currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName());

      setEdmMultiplicity(propertyView.getJPAAttribute().getPersistentAttributeType());

      AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
      if (annotatedElement != null) {
        joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
        if (joinColumn != null) {
          columnName = joinColumn.name();
          referencedColumnName = joinColumn.referencedColumnName();
        }

      }
      ownerPropertyName = propertyView.getJPAAttribute().getName();
View Full Code Here

    if (annotatedElement != null) {
      Column column = annotatedElement.getAnnotation(Column.class);
      if (column != null) {
        mapping.setJPAColumnName(column.name());
      } else {
        JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
        if (joinColumn != null) {
          mapping.setJPAColumnName(joinColumn.name());
          jpaAttributeName += "." + view.getJPAReferencedAttribute().getName();
        }
      }
    } else {
      ManagedType<?> managedType = jpaAttribute.getDeclaringType();
View Full Code Here

      AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
      if (annotatedElement == null) {
        return;
      }
      JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
      if (joinColumn == null) {
        JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
        if (joinColumns != null) {
          return;
        }
      } else {
        if (joinColumn.insertable() && joinColumn.updatable()) {
          EntityType<?> referencedEntityType = metaModel.entity(jpaAttribute.getJavaType());
          for (Attribute<?, ?> referencedAttribute : referencedEntityType.getAttributes()) {
            AnnotatedElement annotatedElement2 = (AnnotatedElement) referencedAttribute.getJavaMember();
            if (annotatedElement2 != null) {
              Column referencedColumn = annotatedElement2.getAnnotation(Column.class);
              if (referencedColumn != null && referencedColumn.name().equals((joinColumn.referencedColumnName()))) {
                currentRefAttribute = referencedAttribute;
                currentSimpleProperty = new SimpleProperty();
                properties.add(buildSimpleProperty(currentRefAttribute, currentSimpleProperty));
                break;
              }
View Full Code Here

  private class JavaMemberMock extends JPAJavaMemberMock {
    @SuppressWarnings("unchecked")
    @Override
    public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
      JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
      EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
      EasyMock.expect(joinColumn.name()).andReturn("SOID");

      EasyMock.replay(joinColumn);
      return (T) joinColumn;
    }
View Full Code Here

      };
    }
    else {
      joinColumns = new Ejb3JoinColumn[annJoins.length];
      JoinColumn annJoin;
      int length = annJoins.length;
      for (int index = 0; index < length; index++) {
        annJoin = annJoins[index];
        Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();
        currentJoinColumn.setImplicit( true );
View Full Code Here

TOP

Related Classes of javax.persistence.JoinColumn

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.