Package com.avaje.ebeaninternal.server.deploy

Examples of com.avaje.ebeaninternal.server.deploy.BeanTable


    if (where != null) {
      prop.setExtraWhere(where.clause());
    }

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

    JoinColumns joinColumns = get(prop, JoinColumns.class);
    if (joinColumns != null) {
      prop.getTableJoin().addJoinColumn(true, joinColumns.value(), beanTable);
    }

    JoinTable joinTable = get(prop, JoinTable.class);
    if (joinTable != null) {
      if (prop.isManyToMany()){
        // expected this
        readJoinTable(joinTable, prop);

      } else {
        // OneToMany in theory
        prop.getTableJoin().addJoinColumn(true, joinTable.joinColumns(), beanTable);
      }
    }

    if (prop.getMappedBy() != null){
      // the join is derived by reversing the join information
      // from the mapped by property.
      // Refer BeanDescriptorManager.readEntityRelationships()
      return;
    }

    if (prop.isManyToMany()){
      manyToManyDefaultJoins(prop);
      return;
    }


    if (!prop.getTableJoin().hasJoinColumns() && beanTable != null){

      // use naming convention to define join (based on the bean name for this side of relationship)     
      // A unidirectional OneToMany or OneToMany with no mappedBy property
       
            NamingConvention nc = factory.getNamingConvention();

            String fkeyPrefix = null;
            if (nc.isUseForeignKeyPrefix()){
                fkeyPrefix = nc.getColumnFromProperty(descriptor.getBeanType(), descriptor.getName());
            }
        
      // Use the owning bean table to define the join
      BeanTable owningBeanTable = factory.getBeanTable(descriptor.getBeanType());
      owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false);
    }
  }
View Full Code Here


      } else {
        // intersection table already defined (by @JoinTable)
        intTableName = intJoin.getTable();
      }

      BeanTable localTable = factory.getBeanTable(descriptor.getBeanType());
      BeanTable otherTable = factory.getBeanTable(prop.getTargetType());

      final String localTableName = localTable.getUnqualifiedBaseTable();
      final String otherTableName = otherTable.getUnqualifiedBaseTable();

      if (intTableName == null){
        // define intersection table name
        intTableName = getM2MJoinTableName(localTable, otherTable);

        intJoin.setTable(intTableName);
        intJoin.setType(SqlJoinType.OUTER);
      }

    DeployTableJoin destJoin = prop.getTableJoin();


      if (intJoin.hasJoinColumns() && destJoin.hasJoinColumns()){
        // already defined the foreign key columns etc
        return;
      }
      if (!intJoin.hasJoinColumns()){
        // define foreign key columns
      BeanProperty[] localIds = localTable.getIdProperties();
      for (int i = 0; i < localIds.length; i++) {
        // add the source to intersection join columns
        String fkCol = localTableName+"_"+localIds[i].getDbColumn();
        intJoin.addJoinColumn(new DeployTableJoinColumn(localIds[i].getDbColumn(), fkCol));
      }
      }

    if (!destJoin.hasJoinColumns()){
        // define inverse foreign key columns
      BeanProperty[] otherIds = otherTable.getIdProperties();
      for (int i = 0; i < otherIds.length; i++) {
        // set the intersection to dest table join columns
        final String fkCol = otherTableName+"_"+otherIds[i].getDbColumn();
        destJoin.addJoinColumn(new DeployTableJoinColumn(fkCol, otherIds[i].getDbColumn()));
      }
View Full Code Here

    } else {
      manyProp.setTargetType(targetType);
    }

    // find the other many table (not intersection)
    BeanTable assoc = factory.getBeanTable(targetType);
    if (assoc == null) {
          String msg = errorMsgMissingBeanTable(targetType, manyProp.getFullBeanName());
          throw new RuntimeException(msg);
    }
View Full Code Here

      targetType = manyProp.getTargetType();
    } else {
      manyProp.setTargetType(targetType);
    }

    BeanTable assoc = factory.getBeanTable(targetType);
    if (assoc == null) {
          String msg = errorMsgMissingBeanTable(targetType, manyProp.getFullBeanName());
          throw new RuntimeException(msg);
    }
View Full Code Here

              prop.getTableJoin().setType(SqlJoinType.INNER);
          }
        }

        // 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);
        if (joinColumns != null) {
            prop.getTableJoin().addJoinColumn(false, joinColumns.value(), beanTable);
        }

        JoinTable joinTable = get(prop, JoinTable.class);
        if (joinTable != null) {
            prop.getTableJoin().addJoinColumn(false, joinTable.joinColumns(), beanTable);
        }

        info.setBeanJoinType(prop, prop.isNullable());

        if (!prop.getTableJoin().hasJoinColumns() && beanTable != null) {

            if (prop.getMappedBy() != null) {
                // the join is derived by reversing the join information
                // from the mapped by property.
                // Refer BeanDescriptorManager.readEntityRelationships()

            } else {
                // use naming convention to define join.
                NamingConvention nc = factory.getNamingConvention();
               
                String fkeyPrefix = null;
                if (nc.isUseForeignKeyPrefix()){
                    fkeyPrefix = nc.getColumnFromProperty(beanType, prop.getName());
                }

                beanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), true);
            }
        }
    }
View Full Code Here

        DeployBeanPropertyAssocOne<?> beanProp = (DeployBeanPropertyAssocOne<?>) prop;

        setCascadeTypes(propAnn.cascade(), beanProp.getCascadeInfo());

        BeanTable assoc = factory.getBeanTable(beanProp.getPropertyType());
        if (assoc == null) {
            String msg = errorMsgMissingBeanTable(beanProp.getPropertyType(), prop.getFullBeanName());
            throw new RuntimeException(msg);
        }
        beanProp.setBeanTable(assoc);
View Full Code Here

            prop.setOneToOneExported(true);
        }

        setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo());

        BeanTable assoc = factory.getBeanTable(prop.getPropertyType());
        if (assoc == null) {
            String msg = errorMsgMissingBeanTable(prop.getPropertyType(), prop.getFullBeanName());
            throw new RuntimeException(msg);
        }
View Full Code Here

TOP

Related Classes of com.avaje.ebeaninternal.server.deploy.BeanTable

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.