コード例 #1
0
ファイル: ObjEntity.java プロジェクト: vintikjeny/cayenne
  /**
   * Clears all the mapping between this obj entity and its current db entity. Clears mapping
   * between entities, attributes and relationships.
   */
  public void clearDbMapping() {
    if (dbEntityName == null) {
      return;
    }

    for (ObjAttribute attribute : getAttributeMap().values()) {
      DbAttribute dbAttr = attribute.getDbAttribute();
      if (dbAttr != null) {
        attribute.setDbAttributePath(null);
      }
    }

    for (ObjRelationship relationship : getRelationships()) {
      relationship.clearDbRelationships();
    }

    dbEntityName = null;
  }
コード例 #2
0
ファイル: ObjEntity.java プロジェクト: vintikjeny/cayenne
  /**
   * Returns ObjAttribute of this entity that maps to <code>dbAttribute</code> parameter. Returns
   * null if no such attribute is found.
   */
  public ObjAttribute getAttributeForDbAttribute(DbAttribute dbAttribute) {

    for (ObjAttribute next : getAttributeMap().values()) {

      if (next instanceof EmbeddedAttribute) {
        ObjAttribute embeddedAttribute =
            ((EmbeddedAttribute) next).getAttributeForDbPath(dbAttribute.getName());
        if (embeddedAttribute != null) {
          return embeddedAttribute;
        }
      } else {
        if (next.getDbAttribute() == dbAttribute) {
          return next;
        }
      }
    }

    return null;
  }