예제 #1
1
  private static ORMSQLContext buildCreateColumnList(
      Object obj, com.corm.mapping.generated.Class clazz, String action, String ignoreFor) {

    //		String catalog = clazz.getKeyspace();
    String table = clazz.getColumnFamily();
    StringBuilder builder = new StringBuilder();
    builder.append(action + " ").append(table + " (");
    Set<String> columns = ORMPropertyListBuilder.build(obj, clazz.getName(), ignoreFor);
    Set<com.corm.mapping.generated.Column> refined =
        new LinkedHashSet<com.corm.mapping.generated.Column>();

    for (String column : columns) {
      //			String name = column.getName();
      builder.append(column + ',');
    }

    builder.trimToSize();
    builder = new StringBuilder(builder.substring(0, builder.length() - 1));
    builder.append(") VALUES (");

    for (int i = 0; i < columns.size(); i++) {
      //			if(column.isInject() && !canIgnore(column,ignoreFor)){
      //				builder.append(column.getHint()+",");
      //			}else{
      //				refined.add(column);
      builder.append("?,");
      //			}
    }

    String sql = builder.substring(0, builder.length() - 1) + ")";
    builder.setLength(0);
    builder = null;
    return new ORMSQLContext(sql, refined);
  }
예제 #2
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;
  }
예제 #3
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);
  }
예제 #4
0
 public static void register(com.corm.mapping.generated.Class clazz) {
   mpSelectSQL.put(clazz.getName(), buildSelectColumnList(clazz));
   ORMClassRegistry.register(clazz);
 }