Package javax.persistence

Examples of javax.persistence.JoinColumn


  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


      AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
      joinColumnNames = null;
      if (annotatedElement == null) {
        return;
      }
      JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
      if (joinColumn == null) {
        JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
        if (joinColumns != null) {
          for (JoinColumn jc : joinColumns.value()) {
            buildForeignKey(jc, jpaAttribute);
View Full Code Here

          }
        }

        // check for manually defined joins
        BeanTable beanTable = prop.getBeanTable();
        JoinColumn joinColumn = get(prop, JoinColumn.class);
        if (joinColumn != null) {
          prop.getTableJoin().addJoinColumn(false, joinColumn, beanTable);
          if (!joinColumn.updatable()) {
            prop.setDbUpdateable(false);
          }
          if (!joinColumn.nullable()) {
            prop.setNullable(false);
          }
        }

        JoinColumns joinColumns = get(prop, JoinColumns.class);
View Full Code Here

                //check for the special case, @Id with @JoinColumn and @ManyToOne
                ManyToOne manyToOne = f.getAnnotation(ManyToOne.class);
                if (manyToOne == null) {
                    columns[idx] = f.getName().toUpperCase();
                } else {
                    JoinColumn joinColumn = f.getAnnotation(JoinColumn.class);
                    columns[idx] = joinColumn.name();
                    if (columns[idx].isEmpty()) {
                        columns[idx] = f.getName().toUpperCase();
                    }
                }
            }
View Full Code Here

    private static List<JoinColumn> getJoinColumns(Field field) {
        if (field == null) {
            return null;
        }
       
        JoinColumn colSpec = field.getAnnotation(JoinColumn.class);
       
        if (colSpec != null) {
            //a single join column specified
            return Collections.singletonList(colSpec);
        } else {
View Full Code Here

    private static String[] referencedJoinColumnNames(Field field) {
        if (field == null) {
            return null;
        }
       
        JoinColumn colSpec = field.getAnnotation(JoinColumn.class);
       
        if (colSpec != null) {
            //a single join column specified
            return new String[] { colSpec.referencedColumnName().toUpperCase() };
        } else {
            //see, if there are more join cols
            JoinColumns joinColumns = field.getAnnotation(JoinColumns.class);
            if (joinColumns != null) {
                JoinColumn[] cols = joinColumns.value();
View Full Code Here

        RelationshipTranslation translation = new RelationshipTranslation();

        if (toField == null) {
            JoinTable t = fromField.getAnnotation(JoinTable.class);
            JoinColumn c = fromField.getAnnotation(JoinColumn.class);
            if (t != null) {
                analyzeJoinTable(translation, t);
            } else if (c != null) {
                //join column represents the column in the target table.
                String fromColumn = getColumnName(fromField);
                if (fromColumn == null) {
                    translation.setFromColumns(relationship.getFrom().getTranslation().getPkColumns());
                } else {
                    translation.setFromColumns(new String[] { fromColumn });
                }

                translation.setToColumns(joinColumnNames(new JoinColumn[] { c }));
            } else {
                throw new IllegalArgumentException("Default mappings on @OneToMany not implemented.");
            }

        } else {
            String fromColumn = getColumnName(fromField);
            if (fromColumn == null) {
                translation.setFromColumns(relationship.getFrom().getTranslation().getPkColumns());
            } else {
                translation.setFromColumns(new String[] { fromColumn });
            }

            String toColumn = getColumnName(toField);
            if (toColumn == null) {
                AnnotatedField fullField = getFieldWithFullAnnotations(toField);
                JoinColumn joinColumn = fullField.getAnnotation(JoinColumn.class);
                if (joinColumn == null) {
                    translation.setToColumns(relationship.getTo().getTranslation().getPkColumns());
                } else {
                    translation.setToColumns(joinColumnNames(new JoinColumn[] { joinColumn }));
                }
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

//                return;
//              }
            }
         
            System.out.println("KEKEKE");
            JoinColumn joinColumn = joinTablaAnnotation.joinColumns()[0];
            JoinColumn inverseJoinColumn = joinTablaAnnotation.inverseJoinColumns()[0];
         
            if(joinColumn == null) {
                throw new ActivationException("Exception join column can`t be null ! Please check your data!");
                        }
                        // TODO refactor this
                        if(joinColumn.referencedColumnName() != null || !joinColumn.referencedColumnName().equals("")){
              joinColumnOne = joinColumn.referencedColumnName();
              if(joinColumn.columnDefinition() != null || !joinColumn.columnDefinition().equals("")){
                joinColumnDefinition = joinColumn.columnDefinition();
              }
            }

            if(inverseJoinColumn != null){
                            throw new ActivationException("Exception inverse join column can`t be null! Please check your data!");
                        }
                        // TODO refactor this
            if(inverseJoinColumn.referencedColumnName() != null || !inverseJoinColumn.referencedColumnName().equals("")){
              joinColumnTwo = inverseJoinColumn.referencedColumnName();
              if(inverseJoinColumn.columnDefinition() != null || !inverseJoinColumn.columnDefinition().equals("")){
                inverseJoinColumDefiniton = inverseJoinColumn.columnDefinition();
              }
            }
          }
         
          ParameterizedType stringListType = (ParameterizedType) neededField.getGenericType();
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.