예제 #1
0
  private static String buildSelectColumnList(com.corm.mapping.generated.Class clazz) {
    //		String catalog = clazz.getKeyspace();
    String table = clazz.getColumnFamily();
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT ");

    for (com.corm.mapping.generated.Column Column : clazz.getColumn()) {

      String column = Column.getName();
      builder.append(column + ',');
    }
    builder.trimToSize();
    String ret = builder.substring(0, builder.length() - 1) + " FROM " + table + " ";
    builder.setLength(0);
    builder = null;
    return ret;
  }
예제 #2
0
  private static ORMSQLContext buildDeleteColumnList(
      Object obj, com.corm.mapping.generated.Class clazz) {

    //		String catalog = clazz.getKeyspace();
    String table = clazz.getColumnFamily();
    StringBuilder builder = new StringBuilder();
    builder.append("DELETE FROM " + table + " where ");

    Set<com.corm.mapping.generated.Column> properties =
        ORMPropertyListBuilder.buildDelete(obj, clazz.getName());

    for (com.corm.mapping.generated.Column column : properties) {
      String name = column.getName();
      builder.append(name).append("=? AND ");
    }

    builder.trimToSize();

    int backTrack = (properties.size() == 0) ? 4 : 0;

    String sql = builder.substring(0, builder.length() - backTrack);

    return new ORMSQLContext(sql, properties);
  }