Examples of AmberColumn


Examples of com.caucho.amber.table.AmberColumn

                             fieldType.getName(), fieldName));
    }

    AmberType amberType = persistenceUnit.createType(fieldType);

    AmberColumn fieldColumn = createColumn(sourceType, field, fieldName,
                                      columnAnn, amberType, columnConfig);

    VersionField version = new VersionField(sourceType, fieldName);
    version.setColumn(fieldColumn);
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

    else if (columnConfig != null && ! columnConfig.getName().equals(""))
      name = columnConfig.getName();
    else
      name = toSqlName(fieldName);

    AmberColumn column = null;

    if (entityType == null) { // embeddable
      column = new AmberColumn(null, name, amberType);
    }
    else if (columnAnn != null && ! columnAnn.table().equals("")) {
      String tableName = columnAnn.table();
      AmberTable table;

      table = entityType.getSecondaryTable(tableName);

      if (table == null)
        throw error(field, L.l("{0} @Column(table='{1}') is an unknown secondary table.",
                               fieldName,
                               tableName));

      column = table.createColumn(name, amberType);
    }
    else if (entityType.getTable() != null)
      column = entityType.getTable().createColumn(name, amberType);
    else { // jpa/0ge2: MappedSuperclassType
      column = new AmberColumn(null, name, amberType);
    }

    if (column != null && columnAnn != null) {
      // primaryKey = column.primaryKey();
      column.setUnique(columnAnn.unique());
      column.setNotNull(! columnAnn.nullable());
      //insertable = column.insertable();
      //updateable = column.updatable();
      if (! "".equals(columnAnn.columnDefinition()))
        column.setSQLType(columnAnn.columnDefinition());
      column.setLength(columnAnn.length());
      int precision = columnAnn.precision();
      if (precision < 0) {
        throw error(field, L.l("{0} @Column precision cannot be less than 0.",
                               fieldName));
      }

      int scale = columnAnn.scale();
      if (scale < 0) {
        throw error(field, L.l("{0} @Column scale cannot be less than 0.",
                               fieldName));
      }

      // this test implicitly works for case where
      // precision is not set explicitly (ie: set to 0 by default)
      // and scale is set
      if (scale > precision) {
        throw error(field, L.l("{0} @Column scale cannot be greater than precision. Must set precision to a non-zero value before setting scale.",
                               fieldName));
      }

      if (precision > 0) {
        column.setPrecision(precision);
        column.setScale(scale);
      }
    }

    return column;
  }
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

    out.print("com.caucho.amber.entity.AmberEntityHome home, ");
    out.println("Object key)");
    out.println("{");
    out.pushDepth();

    AmberColumn discriminator = _entityType.getDiscriminator();

    if (_entityType.isAbstractClass()
        || _entityType.getId() == null
        || discriminator == null) {
      out.println("return __caucho_home_new(home, key, aConn, null);");
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

   * Initialize the table.
   */
  public void init()
    throws ConfigException
  {
    AmberColumn keyColumn = getTable().createColumn(_keyColumn,
                                               StringType.create());
    keyColumn.setPrimaryKey(true);
    keyColumn.setLength(254);

    AmberColumn valueColumn = getTable().createColumn(_valueColumn,
                                                 LongType.create());
  }
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

  {
    String fieldName = field.getName();

    ColumnConfig column = _overrideMap.get(fieldName);

    AmberColumn oldColumn = field.getColumn();
    // XXX: deal with types
    AbstractField newField = (AbstractField) field.override(_entityType);

    if (column != null) {
      AmberTable table = _entityType.getTable();
      AmberColumn newColumn = table.createColumn(column.getName(),
              oldColumn.getType());

      newField.setColumn(newColumn);

      newField.init();
 
      return newField;
    }
    else {
      AmberTable table = _entityType.getTable();
      AmberColumn newColumn = table.createColumn(oldColumn.getName(),
              oldColumn.getType());

      newField.setColumn(newColumn);

      newField.init();
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

      EntityType entityType = item.getEntityType();

      // jpa/0l44
      if (entityType != null) {
        AmberColumn discriminator = entityType.getDiscriminator();

        // jpa/0l43
        if (entityType instanceof SubEntityType &&
            discriminator != null) {
          // jpa/0l12, jpa/0l4b

          if (item.getTable() == discriminator.getTable()) {
            if (hasExpr)
              cb.append(" and ");
            else {
              cb.append(" where ");
              hasExpr = true;
            }

            cb.append("(" + item.getName() + "." + discriminator.getName() + " = ");
            cb.append("'" + entityType.getDiscriminatorValue() + "')");
          }
        }
      }
    }
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

          EntityType entityType = item.getEntityType();

          // jpa/0l44
          if (entityType != null) {
            AmberColumn discriminator = entityType.getDiscriminator();

            // jpa/0l43
            if (entityType instanceof SubEntityType &&
                discriminator != null) {
              // jpa/0l12, jpa/0l4b

              if (item.getTable() == discriminator.getTable()) {
                if (isFirst) {
                  isFirst = false;
                  cb.append(" where ");
                }
                else
                  cb.append(" and ");

                cb.append("(" + item.getName() + "." + discriminator.getName() + " = ");
                cb.append("'" + entityType.getDiscriminatorValue() + "')");
              }
            }
          }
        }
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

      String refName = joinColumn.getReferencedColumnName();

      IdField id = getField(idFields, refName);

      AmberColumn column = id.getColumns().get(0);

      foreignColumn = mapTable.createForeignColumn(name, column);

      columns.add(foreignColumn);
    }
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

    // jpa/0w24
    property.setType(amberType);

    property.setLazy(isFetchLazy());

    AmberColumn fieldColumn = createColumn(amberType);
    property.setColumn(fieldColumn);

    /*
      field.setInsertable(insertable);
View Full Code Here

Examples of com.caucho.amber.table.AmberColumn

  private AmberColumn createColumn(AmberType amberType)
    throws ConfigException
  {
    String name = _column.getName();

    AmberColumn column = null;

    if (_sourceType instanceof EntityType) {
      EntityType entityType = (EntityType) _sourceType;
     
      String tableName = _column.getTable();
      AmberTable table;

      if (tableName.equals("")) {
        table = entityType.getTable();

        if (table == null)
          throw error(_field, L.l("{0} @Column(name='{1}') is an unknown table.",
                                  _fieldName,
                                  name));
      }
      else {
        table = entityType.getSecondaryTable(tableName);

        if (table == null)
          throw error(_field, L.l("{0} @Column(table='{1}') is an unknown secondary table.",
                                  _fieldName,
                                  tableName));
      }

      column = table.createColumn(name, amberType);
    }
    else { // embeddable
      column = new AmberColumn(null, name, amberType);
    }

    // primaryKey = column.primaryKey();
    column.setUnique(_column.isUnique());
    column.setNotNull(! _column.isNullable());
    //insertable = column.insertable();
    //updateable = column.updatable();
    if (! "".equals(_column.getColumnDefinition()))
      column.setSQLType(_column.getColumnDefinition());
     
    column.setLength(_column.getLength());
    int precision = _column.getPrecision();
    if (precision < 0) {
      throw error(_field, L.l("{0} @Column precision cannot be less than 0.",
           _fieldName));
    }

    int scale = _column.getScale();
    if (scale < 0) {
      throw error(_field, L.l("{0} @Column scale cannot be less than 0.",
           _fieldName));
    }

    // this test implicitly works for case where
    // precision is not set explicitly (ie: set to 0 by default)
    // and scale is set
    if (precision < scale) {
      throw error(_field, L.l("{0} @Column scale cannot be greater than precision. Must set precision to a non-zero value before setting scale.",
           _fieldName));
    }

    if (precision > 0) {
      column.setPrecision(precision);
      column.setScale(scale);
    }

    return column;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.