Package com.caucho.amber.table

Examples of com.caucho.amber.table.AmberTable


    }

    out.println("if ((__caucho_loadMask_" + group + " & " + mask + "L) != 0)");
    out.println("  return;");

    AmberTable table = _entityType.getTable();

    String from = null;
    String select = null;
    String where = null;

    String subSelect = null;
    AmberTable mainTable = null;
    String tableName = null;

    select = _entityType.generateLoadSelect(table, "o", _index);

    if (select != null) {
      from = table.getName() + " o";
      where = _entityType.getId().generateMatchArgWhere("o");
      mainTable = table;
      tableName = "o";
    }

    ArrayList<AmberTable> subTables = _entityType.getSecondaryTables();

    for (int i = 0; i < subTables.size(); i++) {
      AmberTable subTable = subTables.get(i);

      subSelect = _entityType.generateLoadSelect(subTable, "o" + i, _index);

      if (subSelect == null)
        continue;

      if (select != null)
        select = select + ", " + subSelect;
      else
        select = subSelect;

      if (from != null)
        from = from + ", " + subTable.getName() + " o" + i;
      else
        from = subTable.getName() + " o" + i;

      if (where != null) {
        LinkColumns link = subTable.getDependentIdLink();

        where = where + " and " + link.generateJoin("o" + i, "o");
      }
      else
        throw new IllegalStateException();
View Full Code Here


  {
    // XXX: jpa/0gg2
    if (getEntitySourceType().getPersistenceUnit().isJPA())
      return;

    AmberTable table = getLinkColumns().getSourceTable();

    out.println("if (\"" + table.getName() + "\".equals(table)) {");
    out.pushDepth();

    String var = "_caucho_field_" + getGetterName();

    out.println("if (" + var + " != null)");
View Full Code Here

    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);
    }
View Full Code Here

  public AmberTable createTable(String tableName)
  {
    if (log.isLoggable(Level.FINER))
      log.log(Level.FINER, "AmberPersistenceUnit.createTable: " + tableName);

    AmberTable table = _tableMap.get(tableName);

    if (table == null) {
      table = new AmberTable(this, tableName);
      table.setCacheTimeout(getTableCacheTimeout());

      _tableMap.put(tableName, table);

      _lazyTable.add(table);
    }
View Full Code Here

  {
    for (IdGenerator gen : _tableGenMap.values())
      gen.start();

    while (_lazyTable.size() > 0) {
      AmberTable table = _lazyTable.remove(0);

      if (getDataSource() == null)
        throw new ConfigException(L.l("{0}: No configured data-source found.",
                                      this));

      if (getCreateDatabaseTables())
        table.createDatabaseTable(this);

      if (getValidateDatabaseTables())
        table.validateDatabaseTable(this);
    }
  }
View Full Code Here

    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

    if (isJPA)
      _targetLoadIndex = loadGroupIndex;
    else
      _targetLoadIndex = relatedType.nextLoadGroupIndex();

    AmberTable sourceTable = relatedType.getTable();

    if (sourceTable == null || ! isJPA) {
      // jpa/0ge3, ejb/0602
      super.init();
      return;
    }

    // jpa/0j67
    setSourceCascadeDelete(isCascade(CascadeType.REMOVE));

    int n = 0;

    if (_joinColumnMap != null)
      n = _joinColumnMap.size();

    ArrayList<ForeignColumn> foreignColumns = new ArrayList<ForeignColumn>();

    EntityType parentType = _targetType;

    ArrayList<AmberColumn> targetIdColumns = _targetType.getId().getColumns();

    while (targetIdColumns.size() == 0) {
      parentType = parentType.getParentType();

      if (parentType == null)
        break;

      targetIdColumns = parentType.getId().getColumns();
    }

    for (AmberColumn keyColumn : targetIdColumns) {
      String columnName;

      columnName = getName() + '_' + keyColumn.getName();

      boolean nullable = true;
      boolean unique = false;

      if (n > 0) {
        JoinColumnConfig joinColumn;

        if (n == 1) {
          joinColumn = (JoinColumnConfig) _joinColumnMap.values().toArray()[0];
        } else
          joinColumn = _joinColumnMap.get(keyColumn.getName());

        if (joinColumn != null) {
          // jpa/0h0d
          if (! "".equals(joinColumn.getName()))
            columnName = joinColumn.getName();

          nullable = joinColumn.isNullable();
          unique = joinColumn.isUnique();
        }
      }
      else {
        JoinColumn joinAnn
          = BaseConfigIntrospector.getJoinColumn(_joinColumnsAnn,
                                                 keyColumn.getName());

        if (joinAnn != null) {
          columnName = joinAnn.name();

          nullable = joinAnn.nullable();
          unique = joinAnn.unique();
        }
      }

      ForeignColumn foreignColumn;

      foreignColumn = sourceTable.createForeignColumn(columnName, keyColumn);

      foreignColumn.setNotNull(! nullable);
      foreignColumn.setUnique(unique);

      foreignColumns.add(foreignColumn);
    }

    LinkColumns linkColumns = new LinkColumns(sourceTable,
                                              _targetType.getTable(),
                                              foreignColumns);

    setLinkColumns(linkColumns);

    super.init();

    Id id = getEntityTargetType().getId();
    ArrayList<AmberColumn> keys = id.getColumns();

    if (_linkColumns == null) {
      ArrayList<ForeignColumn> columns = new ArrayList<ForeignColumn>();

      for (int i = 0; i < keys.size(); i++) {
        AmberColumn key = keys.get(i);

        String name;

        if (keys.size() == 1)
          name = getName();
        else
          name = getName() + "_" + key.getName();

        columns.add(sourceTable.createForeignColumn(name, key));
      }

      _linkColumns = new LinkColumns(relatedType.getTable(),
                                     _targetType.getTable(),
                                     columns);
View Full Code Here

    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);
View Full Code Here

      _entityType.addField(embeddedField);

      // XXX: todo ...
      // validateAttributeOverrides(_field, attributeOverridesAnn, type);

      AmberTable sourceTable = _entityType.getTable();

      HashMap<String, AmberColumn> embeddedColumns = new HashMap<String, AmberColumn>();
      HashMap<String, String> fieldNameByColumn = new HashMap<String, String>();

      for (EmbeddedSubField subField : embeddedField.getSubFields()) {
View Full Code Here

    JoinTable joinTableAnn = _field.getAnnotation(javax.persistence.JoinTable.class);

    JoinTableConfig joinTableConfig = getJoinTable();

    AmberTable mapTable = null;

    ArrayList<ForeignColumn> sourceColumns = null;
    ArrayList<ForeignColumn> targetColumns = null;
    AmberPersistenceUnit persistenceUnit = _sourceType.getPersistenceUnit();
View Full Code Here

TOP

Related Classes of com.caucho.amber.table.AmberTable

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.