Esempio n. 1
0
  public static boolean visit(MappingVisitor visitor, SQLIdentifierExpr x) {
    String propertyName = x.getName();

    Property property = null;
    for (Entity entity : visitor.getEntities().values()) {
      property = entity.getProperty(propertyName);
      if (property != null) {
        break;
      }
    }

    if (property == null) {
      throw new DruidMappingException("property not found : " + propertyName);
    }

    String dbColumName = property.getDbColumnName();
    x.setName(dbColumName);

    if (x.getParent() instanceof SQLSelectItem) {
      SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
      if (selectItem.getAlias() == null) {
        selectItem.setAlias('"' + property.getName() + '"');
      }
    }

    return false;
  }
Esempio n. 2
0
  public static boolean visit(MappingVisitor visitor, SQLExprTableSource x) {
    SQLExpr expr = x.getExpr();

    if (expr instanceof SQLIdentifierExpr) {
      SQLIdentifierExpr tableExpr = (SQLIdentifierExpr) expr;
      String entityName = tableExpr.getName();

      Entity entity = visitor.getEntity(entityName);

      if (entity == null) {
        throw new DruidMappingException("entity not foudn : " + entityName);
      }

      tableExpr.setName(entity.getTableName());
    }

    if (x.getAlias() != null) {
      visitor.getTableSources().put(x.getAlias(), x);
    }

    return false;
  }