Search in sources :

Example 1 with ColumnSourceByValuesBuilder

use of org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder in project qi4j-sdk by Qi4j.

the class PostgreSQLIndexing method createInsertStatementWithAutoGeneratedIDForEntitiesTable.

@Override
protected InsertStatement createInsertStatementWithAutoGeneratedIDForEntitiesTable(String schemaName, String tableName, SQLVendor vendor) {
    ModificationFactory m = vendor.getModificationFactory();
    LiteralFactory l = vendor.getLiteralFactory();
    TableReferenceFactory t = vendor.getTableReferenceFactory();
    ColumnsFactory c = vendor.getColumnsFactory();
    ColumnSourceByValuesBuilder columnBuilder = m.columnSourceByValues();
    columnBuilder.addValues(ValueSource.Default.INSTANCE);
    for (Integer x = 1; x < AMOUNT_OF_COLUMNS_IN_ENTITY_TABLE; ++x) {
        columnBuilder.addValues(l.param());
    }
    return ((PgSQLInsertStatementBuilder) m.insert()).setReturningClause(vendor.getQueryFactory().columnsBuilder().addUnnamedColumns(c.colName(DBNames.ENTITY_TABLE_PK_COLUMN_NAME)).createExpression()).setTableName(t.tableName(schemaName, tableName)).setColumnSource(columnBuilder.createExpression()).createExpression();
}
Also used : ModificationFactory(org.sql.generation.api.grammar.factories.ModificationFactory) TableReferenceFactory(org.sql.generation.api.grammar.factories.TableReferenceFactory) ColumnsFactory(org.sql.generation.api.grammar.factories.ColumnsFactory) ColumnSourceByValuesBuilder(org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder) LiteralFactory(org.sql.generation.api.grammar.factories.LiteralFactory)

Example 2 with ColumnSourceByValuesBuilder

use of org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder in project qi4j-sdk by Qi4j.

the class AbstractSQLIndexing method createInsertStatement.

protected InsertStatement createInsertStatement(String schemaName, String tableName, Integer amountOfColumns, SQLVendor vendor) {
    ModificationFactory m = vendor.getModificationFactory();
    LiteralFactory l = vendor.getLiteralFactory();
    TableReferenceFactory t = vendor.getTableReferenceFactory();
    ColumnSourceByValuesBuilder columnBuilder = m.columnSourceByValues();
    for (Integer x = 0; x < amountOfColumns; ++x) {
        columnBuilder.addValues(l.param());
    }
    return m.insert().setTableName(t.tableName(schemaName, tableName)).setColumnSource(columnBuilder.createExpression()).createExpression();
}
Also used : ModificationFactory(org.sql.generation.api.grammar.factories.ModificationFactory) TableReferenceFactory(org.sql.generation.api.grammar.factories.TableReferenceFactory) ColumnSourceByValuesBuilder(org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder) LiteralFactory(org.sql.generation.api.grammar.factories.LiteralFactory)

Example 3 with ColumnSourceByValuesBuilder

use of org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder in project qi4j-sdk by Qi4j.

the class AbstractSQLIndexing method createPropertyInsert.

protected InsertStatement createPropertyInsert(QNameInfo qNameInfo, SQLVendor vendor) {
    String tableName = qNameInfo.getTableName();
    ModificationFactory m = vendor.getModificationFactory();
    TableReferenceFactory t = vendor.getTableReferenceFactory();
    LiteralFactory l = vendor.getLiteralFactory();
    ColumnSourceByValuesBuilder columnBuilder = m.columnSourceByValues().addValues(l.param(), l.param(), l.param());
    if (qNameInfo.getCollectionDepth() > 0) {
        columnBuilder.addValues(l.func("text2ltree", l.param()));
    }
    columnBuilder.addValues(l.param());
    return m.insert().setTableName(t.tableName(this._state.schemaName().get(), tableName)).setColumnSource(columnBuilder.createExpression()).createExpression();
}
Also used : ModificationFactory(org.sql.generation.api.grammar.factories.ModificationFactory) TableReferenceFactory(org.sql.generation.api.grammar.factories.TableReferenceFactory) ColumnSourceByValuesBuilder(org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder) LiteralFactory(org.sql.generation.api.grammar.factories.LiteralFactory)

Aggregations

ColumnSourceByValuesBuilder (org.sql.generation.api.grammar.builders.modification.ColumnSourceByValuesBuilder)3 LiteralFactory (org.sql.generation.api.grammar.factories.LiteralFactory)3 ModificationFactory (org.sql.generation.api.grammar.factories.ModificationFactory)3 TableReferenceFactory (org.sql.generation.api.grammar.factories.TableReferenceFactory)3 ColumnsFactory (org.sql.generation.api.grammar.factories.ColumnsFactory)1