private ISQLitePreparedStatement prepareInsert(SquidDatabase db, Table table, TableStatement.ConflictAlgorithm conflictAlgorithm) { Object[] placeholders = new Object[table.getProperties().length]; Arrays.fill(placeholders, new Object()); Insert insert = Insert.into(table).columns(table.getProperties()) .values(placeholders).onConflict(conflictAlgorithm); CompiledStatement compiled = insert.compile(db.getCompileContext()); ISQLitePreparedStatement statement = db.prepareStatement(compiled.sql); dbStatementTracking.add(statement); return statement; } }
void bindValuesForInsert(Table table, ISQLitePreparedStatement preparedInsert) { LongProperty rowidProperty = getRowIdProperty(); Property<?>[] allProperties = table.getProperties(); ModelAndIndex modelAndIndex = new ModelAndIndex(this); for (Property<?> property : allProperties) { if (property == rowidProperty) { long rowid = getRowId(); if (rowid == TableModel.NO_ID) { preparedInsert.bindNull(modelAndIndex.index); } else { preparedInsert.bindLong(modelAndIndex.index, rowid); } } else { property.accept(valueBindingVisitor, preparedInsert, modelAndIndex); } modelAndIndex.index++; } }
private ISQLitePreparedStatement prepareInsert(SquidDatabase db, Table table, TableStatement.ConflictAlgorithm conflictAlgorithm) { Object[] placeholders = new Object[table.getProperties().length]; Arrays.fill(placeholders, new Object()); Insert insert = Insert.into(table).columns(table.getProperties()) .values(placeholders).onConflict(conflictAlgorithm); CompiledStatement compiled = insert.compile(db.getCompileContext()); ISQLitePreparedStatement statement = db.prepareStatement(compiled.sql); dbStatementTracking.add(statement); return statement; } }
void bindValuesForInsert(Table table, ISQLitePreparedStatement preparedInsert) { LongProperty rowidProperty = getRowIdProperty(); Property<?>[] allProperties = table.getProperties(); ModelAndIndex modelAndIndex = new ModelAndIndex(this); for (Property<?> property : allProperties) { if (property == rowidProperty) { long rowid = getRowId(); if (rowid == TableModel.NO_ID) { preparedInsert.bindNull(modelAndIndex.index); } else { preparedInsert.bindLong(modelAndIndex.index, rowid); } } else { property.accept(valueBindingVisitor, preparedInsert, modelAndIndex); } modelAndIndex.index++; } }