Beispiel #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;
  }
Beispiel #2
0
  public static void fillSelectList(MappingVisitor visitor, SQLSelectQueryBlock x) {
    Entity entity = visitor.getFirstEntity();

    for (Property item : entity.getProperties().values()) {
      x.getSelectList()
          .add(
              new SQLSelectItem(new SQLIdentifierExpr(item.getName()), '"' + item.getName() + '"'));
    }
  }