@Override
  public void complete() {
    AmberPersistenceUnit persistenceUnit = _sourceType.getPersistenceUnit();

    Class targetClass = getTargetClass();

    if (targetClass == null || void.class.equals(targetClass))
      throw error(
          _field,
          L.l(
              "Can't determine targetEntity for {0}.  @OneToMany properties must target @Entity beans.",
              _fieldName));

    AmberType targetType = persistenceUnit.createType(targetClass);

    if (targetType == null) {
      throw error(
          _field,
          L.l(
              "targetClass '{0}' is not a known element collection class for {1}.  The targetClass of a @ElementCollection must be a basic class.",
              targetClass.getName(), _fieldName));
    }

    /*
    if (_orderBy != null)
      calculateOrderBy(_orderBy);
    */

    addCollection(targetType);
  }
  private void addCollection(AmberType targetType) {
    ElementCollectionField eltCollectionField;

    eltCollectionField = new ElementCollectionField(_sourceType, _fieldName);
    eltCollectionField.setType(targetType);
    eltCollectionField.setLazy(isFetchLazy());

    CollectionTableConfig collectionTableConfig = _collectionTable;

    AmberPersistenceUnit persistenceUnit = _sourceType.getPersistenceUnit();

    String sqlTable = collectionTableConfig.getName();
    AmberTable mapTable = persistenceUnit.createTable(sqlTable);

    HashMap<String, JoinColumnConfig> joinColumnsConfig = collectionTableConfig.getJoinColumnMap();

    ArrayList<ForeignColumn> sourceColumns = null;

    sourceColumns =
        calculateColumns(
            _field,
            _fieldName,
            mapTable,
            _sourceType.getTable().getName() + "_",
            _sourceType,
            joinColumnsConfig);

    eltCollectionField.setAssociationTable(mapTable);
    eltCollectionField.setTable(sqlTable);

    eltCollectionField.setSourceLink(
        new LinkColumns(mapTable, _sourceType.getTable(), sourceColumns));

    _sourceType.addField(eltCollectionField);
  }
 /** Generates the type for the table. */
 public String generateCreateColumnSQL(
     AmberPersistenceUnit manager, int length, int precision, int scale) {
   return manager.getCreateColumnSQL(Types.SMALLINT, length, precision, scale);
 }