Package org.apache.metamodel.insert

Examples of org.apache.metamodel.insert.RowInsertionBuilder


                final Column[] sourceColumns = sourceTable.getColumns();
                final DataSet dataSet = _sourceDataContext.query().from(sourceTable).select(sourceColumns).execute();
                while (dataSet.next()) {
                    final Row row = dataSet.getRow();

                    RowInsertionBuilder insertBuilder = callback.insertInto(targetTable);
                    for (Column column : sourceColumns) {
                        insertBuilder = insertBuilder.value(column.getName(), row.getValue(column));
                    }
                    insertBuilder.execute();
                }
                dataSet.close();
            }
        });
    }
View Full Code Here


        return new InterceptableTableCreationBuilder(tabelCreationBuilder, _tableCreationInterceptors);
    }

    @Override
    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException {
        RowInsertionBuilder rowInsertionBuilder = _updateCallback.insertInto(table);
        if (_rowInsertionInterceptors.isEmpty()) {
            return rowInsertionBuilder;
        }
        return new InterceptableRowInsertionBuilder(rowInsertionBuilder, _rowInsertionInterceptors);
    }
View Full Code Here

    return this;
  }

  @Override
  public void execute() throws MetaModelException {
    RowInsertionBuilder rowInsertionBuilder = _rowInsertionBuilder;
    rowInsertionBuilder = _rowInsertionInterceptors
        .interceptAll(rowInsertionBuilder);
    rowInsertionBuilder.execute();
  }
View Full Code Here

        // insert records
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                RowInsertionBuilder builder = callback.insertInto("my_table").value("name", "row 1").value("foo", true);

                try {
                    Method method = builder.getClass().getDeclaredMethod("createSqlStatement");
                    method.setAccessible(true);
                    Object result = method.invoke(builder);
                    assertEquals("INSERT INTO \"public\".\"my_table\" (name,foo) VALUES (?,?)", result.toString());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }

                builder.execute();

                callback.insertInto("my_table").value("name", "row 2").value("foo", false).execute();
            }
        });
View Full Code Here

        // insert records
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                RowInsertionBuilder builder = callback.insertInto("my_table").value("name", "row 1").value("foo", true);

                try {
                    Method method = builder.getClass().getDeclaredMethod("createSqlStatement");
                    method.setAccessible(true);
                    Object result = method.invoke(builder);
                    assertEquals("INSERT INTO \"public\".\"my_table\" (name,foo) VALUES (?,?)", result.toString());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }

                builder.execute();

                callback.insertInto("my_table").value("name", "row 2").value("foo", false).execute();
            }
        });
View Full Code Here

        // insert records
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                RowInsertionBuilder builder = callback.insertInto("my_table").value("name", "row 1").value("foo", true);

                try {
                    Method method = builder.getClass().getDeclaredMethod("createSqlStatement");
                    method.setAccessible(true);
                    Object result = method.invoke(builder);
                    assertEquals("INSERT INTO \"public\".\"my_table\" (name,foo) VALUES (?,?)", result.toString());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }

                builder.execute();

                callback.insertInto("my_table").value("name", "row 2").value("foo", false).execute();
            }
        });
View Full Code Here

TOP

Related Classes of org.apache.metamodel.insert.RowInsertionBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.