src/main/java/me/zzp/ar/Table.java
public Record create(Object... args) {
    Map<String, Object> data = new HashMap<>();
    data.putAll(foreignKeys);
    for (int i = 0; i < args.length; i += 2) {
      String key = DB.parseKeyParameter(args[i].toString());
      if (!columns.containsKey(key)) {
        throw new IllegalFieldNameException(key);
      }
      Object value = args[i + 1];
      data.put(key, value);
    }

    String[] fields = new String[data.size() + 2];
    int[] types = new int[data.size() + 2];
    Object[] values = new Object[data.size() + 2];
    int index = 0;
    for (Map.Entry<String, Object> e : data.entrySet()) {
      fields[index] = e.getKey();
      types[index] = columns.get(e.getKey());
      values[index] = e.getValue();
      index++;
    }
    Seq.assignAt(fields, Seq.array(-2, -1), "created_at", "updated_at");
    Seq.assignAt(types, Seq.array(-2, -1), Types.TIMESTAMP, Types.TIMESTAMP);
    Seq.assignAt(values, Seq.array(-2, -1), DB.now(), DB.now());

    SqlBuilder sql = new TSqlBuilder();
    sql.insert().into(name).values(fields);
    PreparedStatement call = dbo.prepare(sql.toString(), values, types);
    try {
      int id = 0;
      if (call.executeUpdate() > 0) {
        ResultSet rs = call.getGeneratedKeys();
        if (rs != null && rs.next()) {
          id = rs.getInt(1);
          rs.close();
        }
      }
      return id > 0 ? find(id) : null;
    } catch (SQLException e) {
      throw new SqlExecuteException(sql.toString(), e);
    } finally {
      dbo.close(call);
    }
  }
public Record create(Object... args) {
    Map<String, Object> data = new HashMap<>();
    data.putAll(foreignKeys);
    for (int i = 0; i < args.length; i += 2) {
      String key = DB.parseKeyParameter(args[i].toString());
      if (!columns.containsKey(key)) {
        throw new IllegalFieldNameException(key);
      }
      Object value = args[i + 1];
      data.put(key, value);
    }

    String[] fields = new String[data.size() + 2];
    int[] types = new int[data.size() + 2];
    Object[] values = new Object[data.size() + 2];
    int index = 0;
    for (Map.Entry<String, Object> e : data.entrySet()) {
      fields[index] = e.getKey();
      types[index] = columns.get(e.getKey());
      values[index] = e.getValue();
      index++;
    }
    Seq.assignAt(fields, Seq.array(-2, -1), "created_at", "updated_at");
    Seq.assignAt(types, Seq.array(-2, -1), Types.TIMESTAMP, Types.TIMESTAMP);
    Seq.assignAt(values, Seq.array(-2, -1), DB.now(), DB.now());

    SqlBuilder sql = new TSqlBuilder();
    sql.insert().into(name).values(fields);
    PreparedStatement call = dbo.prepare(sql.toString(), values, types);
    try {
      int id = 0;
      if (call.executeUpdate() > 0) {
        ResultSet rs = call.getGeneratedKeys();
        if (rs != null && rs.next()) {
          id = rs.getInt(1);
          rs.close();
        }
      }
      return id > 0 ? find(id) : null;
    } catch (SQLException e) {
      throw new SqlExecuteException(sql.toString(), e);
    } finally {
      dbo.close(call);
    }
  }
public Record create ( Object ... args ) { Map < String , Object > data = new HashMap <> ( ) ; data . putAll ( foreignKeys ) ; for ( int i = 0 ; i < args . length ; i += 2 ) { String key = DB . parseKeyParameter ( args [ i ] . toString ( ) ) ; if ( ! columns . containsKey ( key ) ) { throw new IllegalFieldNameException ( key ) ; } Object value = args [ i + 1 ] ; data . put ( key , value ) ; } String [ ] fields = new String [ data . size ( ) + 2 ] ; int [ ] types = new int [ data . size ( ) + 2 ] ; Object [ ] values = new Object [ data . size ( ) + 2 ] ; int index = 0 ; for ( Map . Entry < String , Object > e : data . entrySet ( ) ) { fields [ index ] = e . getKey ( ) ; types [ index ] = columns . get ( e . getKey ( ) ) ; values [ index ] = e . getValue ( ) ; index ++ ; } Seq . assignAt ( fields , Seq . array ( - 2 , - 1 ) , "created_at" , "updated_at" ) ; Seq . assignAt ( types , Seq . array ( - 2 , - 1 ) , Types . TIMESTAMP , Types . TIMESTAMP ) ; Seq . assignAt ( values , Seq . array ( - 2 , - 1 ) , DB . now ( ) , DB . now ( ) ) ; SqlBuilder sql = new TSqlBuilder ( ) ; sql . insert ( ) . into ( name ) . values ( fields ) ; PreparedStatement call = dbo . prepare ( sql . toString ( ) , values , types ) ; try { int id = 0 ; if ( call . executeUpdate ( ) > 0 ) { ResultSet rs = call . getGeneratedKeys ( ) ; if ( rs != null && rs . next ( ) ) { id = rs . getInt ( 1 ) ; rs . close ( ) ; } } return id > 0 ? find ( id ) : null ; } catch ( SQLException e ) { throw new SqlExecuteException ( sql . toString ( ) , e ) ; } finally { dbo . close ( call ) ; } }
/* CRUD
/ * CRUD