Package org.sql.generation.api.vendor

Examples of org.sql.generation.api.vendor.SQLVendor


    public final void assemble( ModuleAssembly module )
        throws AssemblyException
    {
        try
        {
            SQLVendor sqlVendor = this.getSQLVendor();
            if( sqlVendor == null )
            {
                throw new AssemblyException( "SQL Vendor could not be determined." );
            }
            module.services( DatabaseSQLServiceComposite.class ).
View Full Code Here


                                  List<Integer> valueSQLTypes, //
                                  Boolean countOnly //
    )
        throws EntityFinderException
    {
        SQLVendor vendor = this.descriptor.metaInfo( SQLVendor.class );

        QueryFactory q = vendor.getQueryFactory();
        TableReferenceFactory t = vendor.getTableReferenceFactory();
        LiteralFactory l = vendor.getLiteralFactory();
        ColumnsFactory c = vendor.getColumnsFactory();

        ColumnReference mainColumn = c.colName( TABLE_NAME_PREFIX + "0", DBNames.ENTITY_TABLE_IDENTITY_COLUMN_NAME );
        if( countOnly )
        {
            mainColumn = c.colExp( l.func( SQLFunctions.COUNT, mainColumn ) );
        }

        QueryBuilder innerBuilder = this.processBooleanExpression(
            whereClause, false, vendor,
            this.createTypeCondition( resultType, vendor ), variables, values, valueSQLTypes );

        QuerySpecificationBuilder mainQuery = q.querySpecificationBuilder();
        mainQuery.getSelect().addUnnamedColumns( mainColumn );
        mainQuery.getFrom().addTableReferences(
            t.tableBuilder( t.table( q.createQuery( innerBuilder.createExpression() ),
                                     t.tableAlias( TABLE_NAME_PREFIX + "0" ) ) ) );

        this.processOrderBySegments( orderBySegments, vendor, mainQuery );

        QueryExpression finalMainQuery = this.finalizeQuery(
            vendor, mainQuery, resultType, whereClause,
            orderBySegments, firstResult, maxResults, variables, values, valueSQLTypes,
            countOnly );

        String result = vendor.toString( finalMainQuery );

        LOGGER.info( "SQL query:\n" + result );
        return result;
    }
View Full Code Here

                                       Map<String, Long> tablePKs )
        throws SQLException
    {
        String schemaName = this._state.schemaName().get();

        SQLVendor vendor = this._vendor;
        ModificationFactory m = vendor.getModificationFactory();
        TableReferenceFactory t = vendor.getTableReferenceFactory();
        LiteralFactory l = vendor.getLiteralFactory();

        // @formatter:off
        PreparedStatement ps = connection.prepareStatement(
            vendor.toString(
                m.insert()
                .setTableName( t.tableName( schemaName, ENTITY_TYPES_TABLE_NAME ) )
                .setColumnSource( m.columnSourceByValues()
                    .addValues( l.param(), l.param() )
                    .createExpression()
                )
                .createExpression()
            )
        );

        try
        {
            Set<String> insertedTypeNames = new HashSet<>();
            for( EntityDescriptor descriptor : appInfo.entityDescriptors.values() )
            {
                for( Class<?> entityType : descriptor.types() )
                {
                    String entityTypeName = entityType.getName();
                    if( !insertedTypeNames.contains( entityTypeName ) )
                    {
                        long pk = tablePKs.get( ENTITY_TYPES_TABLE_NAME );
                        ps.setInt( 1, (int) pk );
                        ps.setString( 2, entityTypeName );
                        ps.executeUpdate();
                        this._state.entityTypePKs().get().put( entityTypeName, (int) pk );
//                      this._state.entityTypeInfos().get().put( entityTypeName, new EntityTypeInfo( descriptor, (int) pk ) );
                        tablePKs.put( ENTITY_TYPES_TABLE_NAME, pk + 1 );
                    }
                }
            }
        }
        finally
        {
            SQLUtil.closeQuietly( ps );
        }

        ps = connection.prepareStatement(
            vendor.toString(
                m.insert()
                .setTableName( t.tableName( schemaName, USED_CLASSES_TABLE_NAME ) )
                .setColumnSource( m.columnSourceByValues()
                    .addValues( l.param(), l.param() )
                    .createExpression()
                )
                .createExpression()
            )
        );

        try
        {
            for( CompositeDescriptorInfo descInfo : appInfo.usedValueComposites )
            {
                String vDescStr = compositeDescriptorToString( descInfo.layer, descInfo.module, descInfo.composite );
                long pk = tablePKs.get( USED_CLASSES_TABLE_NAME );
                ps.setInt( 1, (int) pk );
                ps.setString( 2, vDescStr );
                ps.executeUpdate();
                this._state.usedClassesPKs().get().put( descInfo.composite, (int) pk );
                tablePKs.put( USED_CLASSES_TABLE_NAME, pk + 1 );
            }
        }
        finally
        {
            SQLUtil.closeQuietly( ps );
        }

        ps = connection.prepareStatement(
            vendor.toString(
                m.insert()
                .setTableName( t.tableName( schemaName, ENUM_LOOKUP_TABLE_NAME ) )
                .setColumnSource( m.columnSourceByValues()
                    .addValues( l.param(), l.param() )
                    .createExpression()
                )
                .createExpression()
            )
        );

        try
        {
            for( String enumValue : appInfo.enumValues )
            {
                long pk = tablePKs.get( ENUM_LOOKUP_TABLE_NAME );
                ps.setInt( 1, (int) pk );
                ps.setString( 2, enumValue );
                ps.executeUpdate();
                this._state.enumPKs().get().put( enumValue, (int) pk );
                tablePKs.put( ENUM_LOOKUP_TABLE_NAME, pk + 1 );
            }
        }
        finally
        {
            SQLUtil.closeQuietly( ps );
        }

        Statement stmt = connection.createStatement();
        ps = connection.prepareStatement(
            this.createInsertStatementForQNameInfo( connection, schemaName, vendor ).toString()
        );

        try
        {
            DefinitionFactory d = vendor.getDefinitionFactory();

            for( QNameInfo qNameInfo : this._state.qNameInfos().get().values() )
            {
                QNameType type = qNameInfo.getQNameType();
View Full Code Here

            sqlType = this._primitiveTypes.get( Integer.class );
            valueRefTableName = USED_CLASSES_TABLE_NAME;
            valueRefTablePKColumnName = USED_CLASSES_TABLE_PK_COLUMN_NAME;
        }

        SQLVendor vendor = this._vendor;
        DefinitionFactory d = vendor.getDefinitionFactory();
        TableReferenceFactory t = vendor.getTableReferenceFactory();

        builder
            .addTableElement(
                d.createColumnDefinition( QNAME_TABLE_VALUE_COLUMN_NAME, sqlType,
                                          qNameInfo.getCollectionDepth() > 0 ) )
View Full Code Here

    {
        ResultSet rs = null;
        Long result = defaultPK;
        try
        {
            SQLVendor vendor = this._vendor;
            QueryFactory q = vendor.getQueryFactory();
            // Let's cheat a bit on SQL functions, so we won't need to use heavy query builder.
            // Also, currently there are no arithmetic statements
            rs
            = stmt.executeQuery(
                vendor
                .toString(
                    q.simpleQueryBuilder()
                    .select( "COUNT(" + columnName + ")", "MAX(" + columnName + ") + 1" )
                    .from(
                        vendor.getTableReferenceFactory().tableName( schemaName, tableName ) )
                    .createExpression()
                )
            );
            if( rs.next() )
            {
View Full Code Here

        finally
        {
            SQLUtil.closeQuietly( rs );
        }

        SQLVendor vendor = this._vendor;
        DefinitionFactory d = vendor.getDefinitionFactory();
        TableReferenceFactory t = vendor.getTableReferenceFactory();

        Statement stmt = connection.createStatement();

        // @formatter:off
        try
        {
            if( !schemaFound )
            {
                stmt.execute(
                    vendor.toString(
                        d
                        .createSchemaDefinitionBuilder()
                        .setSchemaName( schemaName )
                        .createExpression()
                    )
                );
                LOGGER.debug( "Database schema created" );
            }

            this.testRequiredCapabilities( connection );
            LOGGER.debug( "Underlying database fullfill required capabilities" );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, USED_CLASSES_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( USED_CLASSES_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                                .get( Integer.class ), false ) )
                        .addTableElement( d.createColumnDefinition( USED_CLASSES_TABLE_CLASS_NAME_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( USED_CLASSES_TABLE_PK_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.UNIQUE )
                                .addColumns( USED_CLASSES_TABLE_CLASS_NAME_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );

            tablePKs.put( USED_CLASSES_TABLE_NAME, 0L );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, ENTITY_TYPES_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( ENTITY_TYPES_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                                .get( ENTITY_TYPE_PK_TYPE ), false ) )
                        .addTableElement( d.createColumnDefinition( ENTITY_TYPES_TABLE_TYPE_NAME_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( ENTITY_TYPES_TABLE_PK_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.UNIQUE )
                                .addColumns( ENTITY_TYPES_TABLE_TYPE_NAME_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );

            tablePKs.put( ENTITY_TYPES_TABLE_NAME, 0L );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, ENTITY_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( ENTITY_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                                .get( ENTITY_PK_TYPE ), false, AutoGenerationPolicy.BY_DEFAULT ) )
                        .addTableElement( d.createColumnDefinition( ENTITY_TABLE_IDENTITY_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createColumnDefinition( ENTITY_TABLE_MODIFIED_COLUMN_NAME, this._primitiveTypes
                                .get( Date.class ), false ) )
                        .addTableElement( d.createColumnDefinition( ENTITY_TABLE_VERSION_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createColumnDefinition( ENTITY_TABLE_APPLICATION_VERSION_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( ENTITY_TABLE_PK_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.UNIQUE )
                                .addColumns( ENTITY_TABLE_IDENTITY_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );
            tablePKs.put( ENTITY_TABLE_NAME, 0L );

            stmt.execute(
                d.createTableDefinitionBuilder()
                .setTableName( t.tableName( schemaName, ENTITY_TYPES_JOIN_TABLE_NAME ) )
                .setTableContentsSource(
                    d.createTableElementListBuilder()
                    .addTableElement( d.createColumnDefinition( ENTITY_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                            .get( ENTITY_PK_TYPE ), false ) )
                    .addTableElement( d.createColumnDefinition( ENTITY_TYPES_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                            .get( ENTITY_TYPE_PK_TYPE ), false ) )
                    .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                            .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                            .addColumns( ENTITY_TABLE_PK_COLUMN_NAME, ENTITY_TYPES_TABLE_PK_COLUMN_NAME )
                            .createExpression()
                        ) )
                    .addTableElement( d.createTableConstraintDefinition( d.createForeignKeyConstraintBuilder()
                            .addSourceColumns( ENTITY_TABLE_PK_COLUMN_NAME )
                            .setTargetTableName( t.tableName( schemaName, ENTITY_TABLE_NAME ) )
                            .addTargetColumns( ENTITY_TABLE_PK_COLUMN_NAME )
                            .setOnDelete( ReferentialAction.CASCADE )
                            .setOnUpdate( ReferentialAction.CASCADE )
                            .createExpression(), ConstraintCharacteristics.INITIALLY_DEFERRED_DEFERRABLE
                        ) )
                    .addTableElement( d.createTableConstraintDefinition( d.createForeignKeyConstraintBuilder()
                            .addSourceColumns( ENTITY_TYPES_TABLE_PK_COLUMN_NAME )
                            .setTargetTableName( t.tableName( schemaName, ENTITY_TYPES_TABLE_NAME ) )
                            .addTargetColumns( ENTITY_TYPES_TABLE_PK_COLUMN_NAME )
                            .setOnDelete( ReferentialAction.RESTRICT )
                            .setOnDelete( ReferentialAction.CASCADE )
                            .createExpression(), ConstraintCharacteristics.NOT_DEFERRABLE ) )
                    .createExpression()
                ).createExpression()
                .toString()
            );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, ENUM_LOOKUP_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( ENUM_LOOKUP_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                                .get( Integer.class ), false ) )
                        .addTableElement( d.createColumnDefinition( ENUM_LOOKUP_TABLE_ENUM_VALUE_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( ENUM_LOOKUP_TABLE_PK_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );

            tablePKs.put( ENUM_LOOKUP_TABLE_NAME, 0L );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, USED_QNAMES_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( USED_QNAMES_TABLE_QNAME_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createColumnDefinition( USED_QNAMES_TABLE_TABLE_NAME_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( USED_QNAMES_TABLE_QNAME_COLUMN_NAME, USED_QNAMES_TABLE_TABLE_NAME_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, ALL_QNAMES_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( ALL_QNAMES_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                                .get( Integer.class ), false ) )
                        .addTableElement( d.createColumnDefinition( ENTITY_TABLE_PK_COLUMN_NAME, this._primitiveTypes
                                .get( ENTITY_PK_TYPE ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( ALL_QNAMES_TABLE_PK_COLUMN_NAME, ENTITY_TABLE_PK_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createForeignKeyConstraintBuilder()
                                .addSourceColumns( ENTITY_TABLE_PK_COLUMN_NAME )
                                .setTargetTableName( t.tableName( schemaName, ENTITY_TABLE_NAME ) )
                                .addTargetColumns( ENTITY_TABLE_PK_COLUMN_NAME )
                                .setOnUpdate( ReferentialAction.CASCADE )
                                .setOnDelete( ReferentialAction.CASCADE )
                                .createExpression(), ConstraintCharacteristics.INITIALLY_DEFERRED_DEFERRABLE
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );

            tablePKs.put( ALL_QNAMES_TABLE_NAME, 0L );

            stmt.execute(
                vendor.toString(
                    d.createTableDefinitionBuilder()
                    .setTableName( t.tableName( schemaName, APP_VERSION_TABLE_NAME ) )
                    .setTableContentsSource(
                        d.createTableElementListBuilder()
                        .addTableElement( d.createColumnDefinition( APP_VERSION_PK_COLUMN_NAME, this._primitiveTypes
                                .get( String.class ), false ) )
                        .addTableElement( d.createTableConstraintDefinition( d.createUniqueConstraintBuilder()
                                .setUniqueness( UniqueSpecification.PRIMARY_KEY )
                                .addColumns( APP_VERSION_PK_COLUMN_NAME )
                                .createExpression()
                            ) )
                        .createExpression()
                    )
                    .createExpression()
                )
            );

            ModificationFactory m = vendor.getModificationFactory();

            PreparedStatement ps = connection.prepareStatement(
                vendor.toString(
                    m.insert()
                    .setTableName( t.tableName( schemaName, APP_VERSION_TABLE_NAME ) )
                    .setColumnSource(
                        m.columnSourceByValues()
                        .addValues( vendor.getLiteralFactory().param() )
                        .createExpression()
                    )
                    .createExpression()
                )
            );
View Full Code Here

    {

        String schemaName = this._state.schemaName().get();
        Statement stmt = connection.createStatement();

        SQLVendor vendor = this._vendor;
        QueryFactory q = vendor.getQueryFactory();
        TableReferenceFactory t = vendor.getTableReferenceFactory();

        try
        {
            // @formatter:off

            q.simpleQueryBuilder()
                .select( ENTITY_TYPES_TABLE_PK_COLUMN_NAME, ENTITY_TYPES_TABLE_TYPE_NAME_COLUMN_NAME )
                .from( t.tableName( schemaName, ENTITY_TYPES_TABLE_NAME ) )
                .createExpression();

            ResultSet rs = stmt.executeQuery(
                vendor.toString(
                    q.simpleQueryBuilder()
                    .select( ENTITY_TYPES_TABLE_PK_COLUMN_NAME, ENTITY_TYPES_TABLE_TYPE_NAME_COLUMN_NAME )
                    .from( t.tableName( schemaName, ENTITY_TYPES_TABLE_NAME ) )
                    .createExpression()
                )
            );

            long pk;
            try
            {
                while( rs.next() )
                {
                    pk = rs.getInt( 1 );
                    String entityTypeName = rs.getString( 2 );
                    this._state.entityTypePKs().get().put( entityTypeName, (int) pk );
//                    this._state.entityTypeInfos().get()
//                        .put( entityTypeName, new EntityTypeInfo( entityDescriptors.get( entityTypeName ), (int) pk ) );
                }
            }
            finally
            {
                SQLUtil.closeQuietly( rs );
            }
            rs = stmt.executeQuery(
                vendor.toString(
                    q.simpleQueryBuilder()
                    .select( USED_CLASSES_TABLE_PK_COLUMN_NAME, USED_CLASSES_TABLE_CLASS_NAME_COLUMN_NAME )
                    .from( t.tableName( schemaName, USED_CLASSES_TABLE_NAME ) )
                    .createExpression()
                )
            );

            try
            {
                while( rs.next() )
                {
                    pk = rs.getInt( 1 );
                    String descriptorTextualFormat = rs.getString( 2 );
                    this._state.usedClassesPKs().get().put(
                        stringToCompositeDescriptor( ValueDescriptor.class,
                                                     this._app.descriptor(),
                                                     descriptorTextualFormat ),
                        (int) pk );
                }
            }
            finally
            {
                SQLUtil.closeQuietly( rs );
            }

            rs = stmt.executeQuery(
                vendor.toString(
                    q.simpleQueryBuilder()
                    .select( ENUM_LOOKUP_TABLE_PK_COLUMN_NAME, ENUM_LOOKUP_TABLE_ENUM_VALUE_NAME )
                    .from( t.tableName( schemaName, ENUM_LOOKUP_TABLE_NAME ) )
                    .createExpression()
                )
View Full Code Here

    @Override
    public void indexEntities( Iterable<EntityState> changedStates )
        throws SQLException
    {
        final String schemaName = this._state.schemaName().get();
        final SQLVendor vendor = this.descriptor.metaInfo( SQLVendor.class );
        Connection connectionTest = AbstractSQLStartup.CONNECTION_FOR_REINDEXING.get();
        boolean connectionFromStartupWasNull = connectionTest == null;
        boolean wasAutoCommit = false;
        boolean wasReadOnly = false;
        if( connectionFromStartupWasNull )
        {
            connectionTest = this._dataSource.getConnection();
        }
        else
        {
            wasAutoCommit = connectionTest.getAutoCommit();
            wasReadOnly = connectionTest.isReadOnly();
        }
        final Connection connection = connectionTest;

        PreparedStatement updateEntityTablePS = null;
        PreparedStatement removeEntityPS = null;
        PreparedStatement insertToPropertyQNamesPS = null;
        PreparedStatement clearEntityDataPS = null;
        Lazy<PreparedStatement, SQLException> queryEntityPKPS = new Lazy<>(
            new LazyInit<PreparedStatement, SQLException>()
            {
                @Override
                public PreparedStatement create()
                throws SQLException
                {
                    return connection.prepareStatement(
                        vendor.toString( createQueryEntityPkByIdentityStatement( schemaName, vendor ) ) );
                }
            } );
        Lazy<PreparedStatement, SQLException> insertToEntityTableAutoGenerated = new Lazy<>(
            new LazyInit<PreparedStatement, SQLException>()
            {
                @Override
                public PreparedStatement create()
                throws SQLException
                {
                    return connection.prepareStatement(
                        createInsertStatementWithAutoGeneratedIDForEntitiesTable( schemaName,
                                                                                  ENTITY_TABLE_NAME,
                                                                                  vendor ).toString() );
                }
            } );
        Lazy<PreparedStatement, SQLException> insertToEntityTypeTablePS = new Lazy<>(
            new LazyInit<PreparedStatement, SQLException>()
            {
                @Override
                public PreparedStatement create()
                throws SQLException
                {
                    return connection.prepareStatement(
                        createInsertEntityTypeStatement( schemaName, vendor ).toString() );
                }
            } );
        Map<QualifiedName, PreparedStatement> qNameInsertPSs = new HashMap<>();

        try
        {
            connection.setAutoCommit( false );
            connection.setReadOnly( false );

            // TODO cache all queries.
            updateEntityTablePS = connection.prepareStatement(
                this.createUpdateEntityTableStatement( schemaName, vendor ).toString() );
            removeEntityPS = connection.prepareStatement(
                this.createDeleteFromEntityTableStatement( schemaName, vendor ).toString() );
            insertToPropertyQNamesPS = connection.prepareStatement(
                vendor.toString( this.createInsertStatement( schemaName,
                                                             DBNames.ALL_QNAMES_TABLE_NAME,
                                                             AMOUNT_OF_COLUMNS_IN_ALL_QNAMES_TABLE,
                                                             vendor ) ) );
            clearEntityDataPS = connection.prepareStatement(
                this.createClearEntityDataStatement( schemaName, vendor ).toString() );
View Full Code Here

    }

    private PreparedStatement createInsertPropertyPS( Connection connection, QNameInfo qNameInfo )
        throws SQLException
    {
        SQLVendor vendor = this.descriptor.metaInfo( SQLVendor.class );
        return connection.prepareStatement( vendor.toString( this.createPropertyInsert( qNameInfo,
                                                                                        vendor ) ) );
    }
View Full Code Here

    private PreparedStatement
        createInsertAssociationPS( Connection connection, QNameInfo qNameInfo )
        throws SQLException
    {
        SQLVendor vendor = this.descriptor.metaInfo( SQLVendor.class );
        return connection.prepareStatement( vendor.toString( this.createAssoInsert( qNameInfo,
                                                                                    vendor,
                                                                                    AMOUNT_OF_COLUMNS_IN_ASSO_TABLE ) ) );
    }
View Full Code Here

TOP

Related Classes of org.sql.generation.api.vendor.SQLVendor

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.