http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ManipulationProcessing.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ManipulationProcessing.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ManipulationProcessing.java
new file mode 100644
index 0000000..9aa0c6a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ManipulationProcessing.java
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql;
+
+import org.apache.polygene.library.sql.generator.grammar.common.SQLConstants;
+import 
org.apache.polygene.library.sql.generator.grammar.manipulation.DropTableOrViewStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.manipulation.pgsql.PgSQLDropTableOrViewStatement;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.ManipulationProcessing.DropTableOrViewStatementProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.ProcessorUtils;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class ManipulationProcessing
+{
+
+    public static class PgSQLDropTableOrViewStatementProcessor extends 
DropTableOrViewStatementProcessor
+    {
+
+        @Override
+        protected void doProcess( SQLProcessorAggregator aggregator, 
DropTableOrViewStatement object,
+                                  StringBuilder builder )
+        {
+            builder.append( "DROP" ).append( SQLConstants.TOKEN_SEPARATOR )
+                   .append( this.getObjectTypes().get( object.whatToDrop() ) 
).append( SQLConstants.TOKEN_SEPARATOR );
+
+            Boolean useIfExists = ( (PgSQLDropTableOrViewStatement) object 
).useIfExists();
+            if( useIfExists )
+            {
+                builder.append( "IF EXISTS" ).append( 
SQLConstants.TOKEN_SEPARATOR );
+            }
+
+            aggregator.process( object.getTableName(), builder );
+
+            ProcessorUtils.processDropBehaviour( object.getDropBehaviour(), 
builder );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ModificationProcessing.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ModificationProcessing.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ModificationProcessing.java
new file mode 100644
index 0000000..100e311
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/ModificationProcessing.java
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql;
+
+import org.apache.polygene.library.sql.generator.grammar.common.SQLConstants;
+import 
org.apache.polygene.library.sql.generator.grammar.modification.InsertStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.modification.pgsql.PgSQLInsertStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.query.SelectColumnClause;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.ModificationProcessing.InsertStatementProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+public class ModificationProcessing
+{
+
+    public static class PgSQLInsertStatementProcessor extends 
InsertStatementProcessor
+    {
+        @Override
+        protected void doProcess( SQLProcessorAggregator processor, 
InsertStatement object,
+                                  StringBuilder builder )
+        {
+            super.doProcess( processor, object, builder );
+
+            SelectColumnClause returning = ( (PgSQLInsertStatement) object 
).getReturningClause();
+            if( returning != null )
+            {
+                builder.append( SQLConstants.NEWLINE ).append( "RETURNING " );
+                processor.process( returning, builder );
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/PostgreSQLProcessor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/PostgreSQLProcessor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/PostgreSQLProcessor.java
new file mode 100644
index 0000000..3dbc059
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/PostgreSQLProcessor.java
@@ -0,0 +1,132 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.polygene.library.sql.generator.Typeable;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BinaryPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.NotRegexpPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.RegexpPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.BigInt;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.SQLInteger;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.SmallInt;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.pgsql.Text;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.ColumnDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.TableCommitAction;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.TableDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.pgsql.PgSQLTableCommitAction;
+import 
org.apache.polygene.library.sql.generator.grammar.literals.TimestampTimeLiteral;
+import 
org.apache.polygene.library.sql.generator.grammar.manipulation.pgsql.PgSQLDropTableOrViewStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.modification.pgsql.PgSQLInsertStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.query.LimitSpecification;
+import 
org.apache.polygene.library.sql.generator.grammar.query.OffsetSpecification;
+import 
org.apache.polygene.library.sql.generator.grammar.query.QuerySpecification;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.BooleanExpressionProcessing.BinaryPredicateProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.ConstantProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefaultSQLProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefinitionProcessing.TableDefinitionProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.DefinitionProcessing.PGColumnDefinitionProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.LiteralExpressionProcessing.PGDateTimeLiteralProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.ManipulationProcessing.PgSQLDropTableOrViewStatementProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.ModificationProcessing.PgSQLInsertStatementProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.QueryProcessing.PgSQLLimitSpecificationProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.QueryProcessing.PgSQLOffsetSpecificationProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.QueryProcessing.PgSQLQuerySpecificationProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class PostgreSQLProcessor extends DefaultSQLProcessor
+{
+
+    private static final Map<Class<? extends Typeable<?>>, SQLProcessor> 
_defaultProcessors;
+
+    private static final Map<Class<? extends BinaryPredicate>, String> 
_defaultPgSQLBinaryOperators;
+
+    static
+    {
+        Map<Class<? extends BinaryPredicate>, String> binaryOperators =
+            new HashMap<Class<? extends BinaryPredicate>, String>(
+                DefaultSQLProcessor.getDefaultBinaryOperators() );
+        binaryOperators.put( RegexpPredicate.class, "~" );
+        binaryOperators.put( NotRegexpPredicate.class, "!~" );
+        _defaultPgSQLBinaryOperators = binaryOperators;
+
+        Map<Class<? extends Typeable<?>>, SQLProcessor> processors =
+            new HashMap<Class<? extends Typeable<?>>, SQLProcessor>(
+                DefaultSQLProcessor.getDefaultProcessors() );
+
+        // Override default processor for date-time
+        processors.put( TimestampTimeLiteral.class, new 
PGDateTimeLiteralProcessor() );
+
+        // Override default processor for column definition
+        Map<Class<?>, String> dataTypeSerials = new HashMap<Class<?>, 
String>();
+        dataTypeSerials.put( BigInt.class, "BIGSERIAL" );
+        dataTypeSerials.put( SQLInteger.class, "SERIAL" );
+        dataTypeSerials.put( SmallInt.class, "SMALLSERIAL" );
+        processors.put( ColumnDefinition.class,
+                        new PGColumnDefinitionProcessor( 
Collections.unmodifiableMap( dataTypeSerials ) ) );
+
+        // Add support for regexp comparing
+        processors
+            .put(
+                RegexpPredicate.class,
+                new BinaryPredicateProcessor( _defaultPgSQLBinaryOperators
+                                                  .get( RegexpPredicate.class 
) ) );
+        processors.put(
+            NotRegexpPredicate.class,
+            new BinaryPredicateProcessor( _defaultPgSQLBinaryOperators
+                                              .get( NotRegexpPredicate.class ) 
) );
+
+        // Add support for PostgreSQL legacy LIMIT/OFFSET
+        processors.put( QuerySpecification.class, new 
PgSQLQuerySpecificationProcessor() );
+        processors.put( OffsetSpecification.class, new 
PgSQLOffsetSpecificationProcessor() );
+        processors.put( LimitSpecification.class, new 
PgSQLLimitSpecificationProcessor() );
+
+        // Add support for "TEXT" data type
+        processors.put( Text.class, new ConstantProcessor( "TEXT" ) );
+
+        // Add "DROP" table commit action
+        Map<TableCommitAction, String> commitActions = new 
HashMap<TableCommitAction, String>(
+            TableDefinitionProcessor.getDefaultCommitActions() );
+        commitActions.put( PgSQLTableCommitAction.DROP, "DROP" );
+        processors.put( TableDefinition.class,
+                        new TableDefinitionProcessor( 
TableDefinitionProcessor.getDefaultTableScopes(),
+                                                      commitActions ) );
+
+        // Add "IF EXISTS" functionality to DROP TABLE/VIEW statements
+        processors.put( PgSQLDropTableOrViewStatement.class,
+                        new PgSQLDropTableOrViewStatementProcessor() );
+
+        // Add support for PostgreSQL-specific INSTERT statement RETURNING 
clause
+        processors.put( PgSQLInsertStatement.class, new 
PgSQLInsertStatementProcessor() );
+
+        _defaultProcessors = processors;
+    }
+
+    public PostgreSQLProcessor( SQLVendor vendor )
+    {
+        super( vendor, _defaultProcessors );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/QueryProcessing.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/QueryProcessing.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/QueryProcessing.java
new file mode 100644
index 0000000..a5bb806
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/pgsql/QueryProcessing.java
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql;
+
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.QueryProcessing.LimitSpecificationProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.QueryProcessing.OffsetSpecificationProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.QueryProcessing.QuerySpecificationProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import org.apache.polygene.library.sql.generator.vendor.PostgreSQLVendor;
+
+/**
+ * @author 2011 Stanislav Muhametsin
+ */
+public class QueryProcessing
+{
+
+    private static final String LEGACY_LIMIT_PREFIX = "LIMIT";
+    private static final String LEGACY_LIMIT_POSTFIX = null;
+    private static final String LEGACY_OFFSET_PREFIX = "OFFSET";
+    private static final String LEGACY_OFFSET_POSTFIX = null;
+
+    public static class PgSQLQuerySpecificationProcessor extends 
QuerySpecificationProcessor
+    {
+        @Override
+        protected boolean isOffsetBeforeLimit( SQLProcessorAggregator 
processor )
+        {
+            return !( (PostgreSQLVendor) processor.getVendor() 
).legacyOffsetAndLimit();
+        }
+    }
+
+    public static class PgSQLOffsetSpecificationProcessor extends 
OffsetSpecificationProcessor
+    {
+        @Override
+        protected String getPrefix( SQLProcessorAggregator processor )
+        {
+            return ( (PostgreSQLVendor) processor.getVendor() 
).legacyOffsetAndLimit() ? LEGACY_OFFSET_PREFIX : super
+                .getPrefix( processor );
+        }
+
+        @Override
+        protected String getPostfix( SQLProcessorAggregator processor )
+        {
+            return ( (PostgreSQLVendor) processor.getVendor() 
).legacyOffsetAndLimit() ? LEGACY_OFFSET_POSTFIX : super
+                .getPostfix( processor );
+        }
+    }
+
+    public static class PgSQLLimitSpecificationProcessor extends 
LimitSpecificationProcessor
+    {
+        @Override
+        protected String getPrefix( SQLProcessorAggregator processor )
+        {
+            return ( (PostgreSQLVendor) processor.getVendor() 
).legacyOffsetAndLimit() ? LEGACY_LIMIT_PREFIX : super
+                .getPrefix( processor );
+        }
+
+        @Override
+        protected String getPostfix( SQLProcessorAggregator processor )
+        {
+            return ( (PostgreSQLVendor) processor.getVendor() 
).legacyOffsetAndLimit() ? LEGACY_LIMIT_POSTFIX : super
+                .getPostfix( processor );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessor.java
new file mode 100644
index 0000000..f0e6f37
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessor.java
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.spi;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public interface SQLProcessor
+{
+    void process( SQLProcessorAggregator aggregator, Typeable<?> object, 
StringBuilder builder );
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessorAggregator.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessorAggregator.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessorAggregator.java
new file mode 100644
index 0000000..cbbe6de
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/spi/SQLProcessorAggregator.java
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.spi;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public interface SQLProcessorAggregator
+{
+    void process( Typeable<?> object, StringBuilder builder );
+
+    SQLVendor getVendor();
+
+    /**
+     * <p>
+     * This provides a way to access current path in a SQL syntax tree. The 
first element is the root one, then the next
+     * one is its child, etc. This stack is read-only.
+     * </p>
+     * <p>
+     * Currently I'm not sure if there is an efficient way to acquire 
read-only stacks rather than creating a new one
+     * from contents of another.
+     * </p>
+     *
+     * @return A current path in SQL syntax tree.
+     */
+    // public Stack<Typeable<?>> getCurrentSyntaxTree();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/DefinitionProcessing.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/DefinitionProcessing.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/DefinitionProcessing.java
new file mode 100644
index 0000000..9bd835e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/DefinitionProcessing.java
@@ -0,0 +1,141 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.sqlite;
+
+import java.util.Map;
+import java.util.Objects;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.AutoGenerationPolicy;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.ColumnDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.TableConstraint;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.TableConstraintDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.TableElement;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.UniqueConstraint;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.UniqueSpecification;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefinitionProcessing.ColumnDefinitionProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefinitionProcessing.SchemaDefinitionProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefinitionProcessing.TableElementListProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+public class DefinitionProcessing
+{
+    public static class SQLListeTableElementListProcessor
+        extends TableElementListProcessor
+    {
+        @Override
+        protected void processTableElement( SQLProcessorAggregator aggregator, 
TableElement object,
+                                            StringBuilder builder, boolean 
hasNext )
+        {
+            if( object.getImplementedType().isAssignableFrom( 
TableConstraintDefinition.class ) )
+            {
+                TableConstraint constraint =
+                    TableConstraintDefinition.class.cast( object 
).getConstraint();
+                if( constraint.getImplementedType().isAssignableFrom( 
UniqueConstraint.class ) )
+                {
+                    UniqueConstraint unique = UniqueConstraint.class.cast( 
constraint );
+                    if( UniqueSpecification.PRIMARY_KEY.equals( 
unique.getUniquenessKind() ) )
+                    {
+                        return; // Skip the whole TableElement for SQL autogen 
support, see below
+                    }
+                }
+            }
+            super.processTableElement( aggregator, object, builder, hasNext );
+        }
+    }
+
+    public static class SQLiteSchemaDefinitionProcessor
+        extends SchemaDefinitionProcessor
+    {
+
+        @Override
+        protected void doProcess( SQLProcessorAggregator aggregator, 
SchemaDefinition object,
+                                  StringBuilder builder )
+        {
+            // Just process schema elements
+            this.processSchemaElements( aggregator, object, builder );
+        }
+    }
+
+    public static class SQLiteColumnDefinitionProcessor
+        extends ColumnDefinitionProcessor
+    {
+        private final Map<Class<?>, String> _autoGenDataTypes;
+
+        public SQLiteColumnDefinitionProcessor( Map<Class<?>, String> 
autoGenDataTypes )
+        {
+            Objects.requireNonNull( autoGenDataTypes, "Data type serial names" 
);
+            this._autoGenDataTypes = autoGenDataTypes;
+        }
+
+        @Override
+        protected void processDataType( SQLProcessorAggregator aggregator, 
ColumnDefinition object,
+                                        StringBuilder builder )
+        {
+            AutoGenerationPolicy autoGenPolicy = 
object.getAutoGenerationPolicy();
+            if( autoGenPolicy == null )
+            {
+                super.processDataType( aggregator, object, builder );
+            }
+            else
+            {
+                // SQLite can't handle the ALWAYS strategy
+                if( AutoGenerationPolicy.BY_DEFAULT.equals( autoGenPolicy ) )
+                {
+                    // SQLite MUST use INTEGER type when autogenerated
+                    Class<?> dtClass = object.getDataType().getClass();
+                    Boolean success = false;
+                    for( Map.Entry<Class<?>, String> entry : 
this._autoGenDataTypes.entrySet() )
+                    {
+                        success = entry.getKey().isAssignableFrom( dtClass );
+                        if( success )
+                        {
+                            builder.append( entry.getValue() );
+                            break;
+                        }
+                    }
+                    if( !success )
+                    {
+                        throw new UnsupportedOperationException( "Unsupported 
column data type "
+                                                                 + 
object.getDataType()
+                                                                 + " for 
auto-generated column." );
+                    }
+                }
+                else
+                {
+                    throw new UnsupportedOperationException( "Unsupported auto 
generation policy: "
+                                                             + autoGenPolicy
+                                                             + "." );
+                }
+            }
+        }
+
+        @Override
+        protected void processMayBeNull( ColumnDefinition object, 
StringBuilder builder )
+        {
+            // Nothing to do - auto generation policy handled in data type orc
+        }
+
+        @Override
+        protected void processAutoGenerationPolicy( ColumnDefinition object, 
StringBuilder builder )
+        {
+            // Nothing to do - auto generation policy handled in data type orc
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/SQLiteProcessor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/SQLiteProcessor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/SQLiteProcessor.java
new file mode 100644
index 0000000..d013c2c
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/transformation/sqlite/SQLiteProcessor.java
@@ -0,0 +1,82 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.implementation.transformation.sqlite;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.polygene.library.sql.generator.Typeable;
+import 
org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+import 
org.apache.polygene.library.sql.generator.grammar.common.TableNameFunction;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.BigInt;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.SQLInteger;
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.SmallInt;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.ColumnDefinition;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.table.TableElementList;
+import 
org.apache.polygene.library.sql.generator.grammar.manipulation.DropSchemaStatement;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefaultSQLProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.NoOpProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.mysql.TableProcessing;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.sqlite.DefinitionProcessing.SQLListeTableElementListProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.sqlite.DefinitionProcessing.SQLiteColumnDefinitionProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.sqlite.DefinitionProcessing.SQLiteSchemaDefinitionProcessor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+public class SQLiteProcessor
+    extends DefaultSQLProcessor
+{
+
+    private static final Map<Class<? extends Typeable<?>>, SQLProcessor> 
_defaultProcessors;
+
+    static
+    {
+        Map<Class<? extends Typeable<?>>, SQLProcessor> processors = new 
HashMap<Class<? extends Typeable<?>>, SQLProcessor>(
+            DefaultSQLProcessor.getDefaultProcessors() );
+
+        // SQLite does not understand schema-qualified table names (or 
anything related to schemas)
+        processors.put( TableNameDirect.class, new 
TableProcessing.MySQLTableNameDirectProcessor() );
+        processors.put( TableNameFunction.class, new 
TableProcessing.MySQLTableNameFunctionProcessor() );
+
+        // Only process schema elements from schema definition, and ignore 
drop schema statements
+        processors.put( SchemaDefinition.class, new 
SQLiteSchemaDefinitionProcessor() );
+        processors.put( DropSchemaStatement.class, new NoOpProcessor() );
+
+        // SQLite MUST use INTEGER PRIMARY KEY AUTOINCREMENT type when 
autogenerated
+        // see http://www.sqlite.org/autoinc.html
+
+        // Override default table element list support
+        processors.put( TableElementList.class, new 
SQLListeTableElementListProcessor() );
+
+        // Override default column definition support
+        Map<Class<?>, String> autoGenDataTypes = new HashMap<Class<?>, 
String>();
+        autoGenDataTypes.put( BigInt.class, "INTEGER PRIMARY KEY 
AUTOINCREMENT" );
+        autoGenDataTypes.put( SQLInteger.class, "INTEGER PRIMARY KEY 
AUTOINCREMENT" );
+        autoGenDataTypes.put( SmallInt.class, "INTEGER PRIMARY KEY 
AUTOINCREMENT" );
+        processors.put( ColumnDefinition.class, new 
SQLiteColumnDefinitionProcessor( autoGenDataTypes ) );
+
+        _defaultProcessors = processors;
+    }
+
+    public SQLiteProcessor( SQLVendor vendor )
+    {
+        super( vendor, _defaultProcessors );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/DefaultVendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/DefaultVendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/DefaultVendor.java
new file mode 100644
index 0000000..c5f96dd
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/DefaultVendor.java
@@ -0,0 +1,254 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.implementation.vendor;
+
+import java.util.Objects;
+import org.apache.polygene.library.sql.generator.Typeable;
+import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.BooleanFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ColumnsFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.DataTypeFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.DefinitionFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.LiteralFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ManipulationFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ModificationFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.QueryFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.TableReferenceFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultBooleanFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultColumnsFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultDataTypeFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultDefinitionFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultLiteralFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultManipulationFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultModificationFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultQueryFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.DefaultTableRefFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.DefaultSQLProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class DefaultVendor
+    implements SQLVendor
+{
+
+    protected interface ProcessorCallback
+    {
+        SQLProcessorAggregator get( SQLVendor vendor );
+    }
+
+    protected interface Callback<T>
+    {
+        T get( SQLVendor vendor, SQLProcessorAggregator processor );
+    }
+
+    protected static final Callback<BooleanFactory> BOOLEAN_FACTORY = new 
Callback<BooleanFactory>()
+    {
+        public BooleanFactory get( SQLVendor vendor, SQLProcessorAggregator 
processor )
+        {
+            return new DefaultBooleanFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<ColumnsFactory> COLUMNS_FACTORY = new 
Callback<ColumnsFactory>()
+    {
+        public ColumnsFactory get( SQLVendor vendor, SQLProcessorAggregator 
processor )
+        {
+            return new DefaultColumnsFactory( vendor, processor );
+        }
+    };
+    protected static final Callback<LiteralFactory> LITERAL_FACTORY = new 
Callback<LiteralFactory>()
+    {
+        public LiteralFactory get( SQLVendor vendor, SQLProcessorAggregator 
processor )
+        {
+            return new DefaultLiteralFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<ModificationFactory> MODIFICATION_FACTORY 
= new Callback<ModificationFactory>()
+    {
+        public ModificationFactory get( SQLVendor vendor, 
SQLProcessorAggregator processor )
+        {
+            return new DefaultModificationFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<QueryFactory> QUERY_FACTORY = new 
Callback<QueryFactory>()
+    {
+        public QueryFactory get( SQLVendor vendor, SQLProcessorAggregator 
processor )
+        {
+            return new DefaultQueryFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<TableReferenceFactory> 
TABLE_REFERENCE_FACTORY = new Callback<TableReferenceFactory>()
+    {
+        public TableReferenceFactory get( SQLVendor vendor, 
SQLProcessorAggregator processor )
+        {
+            return new DefaultTableRefFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<DefinitionFactory> DEFINITION_FACTORY = 
new Callback<DefinitionFactory>()
+    {
+        public DefinitionFactory get( SQLVendor vendor, SQLProcessorAggregator 
processor )
+        {
+            return new DefaultDefinitionFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<ManipulationFactory> MANIPULATION_FACTORY 
= new Callback<ManipulationFactory>()
+    {
+        public ManipulationFactory get( SQLVendor vendor, 
SQLProcessorAggregator processor )
+        {
+            return new DefaultManipulationFactory( vendor, processor );
+        }
+    };
+
+    protected static final Callback<DataTypeFactory> DATA_TYPE_FACTORY = new 
Callback<DataTypeFactory>()
+    {
+        public DataTypeFactory get( SQLVendor vendor, SQLProcessorAggregator 
processor )
+        {
+            return new DefaultDataTypeFactory( vendor, processor );
+        }
+    };
+
+    protected static final ProcessorCallback DEFAULT_PROCESSOR = new 
ProcessorCallback()
+    {
+        public SQLProcessorAggregator get( SQLVendor vendor )
+        {
+            return new DefaultSQLProcessor( vendor );
+        }
+    };
+
+    private final QueryFactory _queryFactory;
+
+    private final BooleanFactory _booleanFactory;
+
+    private final TableReferenceFactory _fromFactory;
+
+    private final LiteralFactory _literalFactory;
+
+    private final ColumnsFactory _columnsFactory;
+
+    private final ModificationFactory _modificationFactory;
+
+    private final DefinitionFactory _definitionFactory;
+
+    private final ManipulationFactory _manipulationFactory;
+
+    private final DataTypeFactory _dataTypeFactory;
+
+    private final SQLProcessorAggregator _processor;
+
+    public DefaultVendor()
+    {
+        this( DEFAULT_PROCESSOR );
+    }
+
+    protected DefaultVendor( ProcessorCallback processor )
+    {
+        this( processor, BOOLEAN_FACTORY, COLUMNS_FACTORY, LITERAL_FACTORY, 
MODIFICATION_FACTORY, QUERY_FACTORY,
+              TABLE_REFERENCE_FACTORY, DEFINITION_FACTORY, 
MANIPULATION_FACTORY, DATA_TYPE_FACTORY );
+    }
+
+    protected DefaultVendor( ProcessorCallback processor, Callback<? extends 
BooleanFactory> booleanFactory,
+                             Callback<? extends ColumnsFactory> 
columnsFactory, Callback<? extends LiteralFactory> literalFactory,
+                             Callback<? extends ModificationFactory> 
modificationFactory, Callback<? extends QueryFactory> queryFactory,
+                             Callback<? extends TableReferenceFactory> 
tableReferenceFactory,
+                             Callback<? extends DefinitionFactory> 
definitionFactory,
+                             Callback<? extends ManipulationFactory> 
manipulationFactory, Callback<? extends DataTypeFactory> dataTypeFactory )
+    {
+        Objects.requireNonNull( processor, "processor" );
+
+        this._processor = processor.get( this );
+        this._booleanFactory = booleanFactory.get( this, this._processor );
+        this._columnsFactory = columnsFactory.get( this, this._processor );
+        this._literalFactory = literalFactory.get( this, this._processor );
+        this._queryFactory = queryFactory.get( this, this._processor );
+        this._modificationFactory = modificationFactory.get( this, 
this._processor );
+        this._fromFactory = tableReferenceFactory.get( this, this._processor );
+        this._definitionFactory = definitionFactory.get( this, this._processor 
);
+        this._manipulationFactory = manipulationFactory.get( this, 
this._processor );
+        this._dataTypeFactory = dataTypeFactory.get( this, this._processor );
+    }
+
+    /**
+     * Note that exactly one string builder is allocated for each statement.
+     */
+    public String toString( SQLStatement statement )
+    {
+        StringBuilder builder = new StringBuilder();
+        this._processor.process( (Typeable<?>) statement, builder );
+        return builder.toString();
+    }
+
+    public QueryFactory getQueryFactory()
+    {
+        return this._queryFactory;
+    }
+
+    public BooleanFactory getBooleanFactory()
+    {
+        return this._booleanFactory;
+    }
+
+    public TableReferenceFactory getTableReferenceFactory()
+    {
+        return this._fromFactory;
+    }
+
+    public LiteralFactory getLiteralFactory()
+    {
+        return this._literalFactory;
+    }
+
+    public ColumnsFactory getColumnsFactory()
+    {
+        return this._columnsFactory;
+    }
+
+    public ModificationFactory getModificationFactory()
+    {
+        return this._modificationFactory;
+    }
+
+    public DefinitionFactory getDefinitionFactory()
+    {
+        return this._definitionFactory;
+    }
+
+    public ManipulationFactory getManipulationFactory()
+    {
+        return this._manipulationFactory;
+    }
+
+    public DataTypeFactory getDataTypeFactory()
+    {
+        return this._dataTypeFactory;
+    }
+
+    protected SQLProcessorAggregator getProcessor()
+    {
+        return this._processor;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/derby/DerbyVendorImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/derby/DerbyVendorImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/derby/DerbyVendorImpl.java
new file mode 100644
index 0000000..d7f47a5
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/derby/DerbyVendorImpl.java
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.implementation.vendor.derby;
+
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.derby.DerbyProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import 
org.apache.polygene.library.sql.generator.implementation.vendor.DefaultVendor;
+import org.apache.polygene.library.sql.generator.vendor.DerbyVendor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+public class DerbyVendorImpl extends DefaultVendor
+    implements DerbyVendor
+{
+
+    protected static final ProcessorCallback DERBY_PROCESSOR = new 
ProcessorCallback()
+    {
+        public SQLProcessorAggregator get( SQLVendor vendor )
+        {
+            return new DerbyProcessor( vendor );
+        }
+    };
+
+    public DerbyVendorImpl()
+    {
+        super( DERBY_PROCESSOR );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/h2/H2VendorImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/h2/H2VendorImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/h2/H2VendorImpl.java
new file mode 100644
index 0000000..c9f1d4a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/h2/H2VendorImpl.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.implementation.vendor.h2;
+
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.h2.H2Processor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import 
org.apache.polygene.library.sql.generator.implementation.vendor.DefaultVendor;
+import org.apache.polygene.library.sql.generator.vendor.H2Vendor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+public class H2VendorImpl extends DefaultVendor
+    implements H2Vendor
+{
+
+    protected static final ProcessorCallback H2_PROCESSOR = new 
ProcessorCallback()
+    {
+
+        public SQLProcessorAggregator get( SQLVendor vendor )
+        {
+            return new H2Processor( vendor );
+        }
+    };
+
+    public H2VendorImpl()
+    {
+        super( H2_PROCESSOR );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/mysql/MySQLVendorImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/mysql/MySQLVendorImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/mysql/MySQLVendorImpl.java
new file mode 100644
index 0000000..a497e59
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/mysql/MySQLVendorImpl.java
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.implementation.vendor.mysql;
+
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.mysql.MySQLProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import 
org.apache.polygene.library.sql.generator.implementation.vendor.DefaultVendor;
+import org.apache.polygene.library.sql.generator.vendor.MySQLVendor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class MySQLVendorImpl extends DefaultVendor
+    implements MySQLVendor
+{
+
+    protected static final ProcessorCallback MYSQL_PROCESSOR = new 
ProcessorCallback()
+    {
+        public SQLProcessorAggregator get( SQLVendor vendor )
+        {
+            return new MySQLProcessor( vendor );
+        }
+    };
+
+    private boolean _legacyLimit;
+
+    public MySQLVendorImpl()
+    {
+        super( MYSQL_PROCESSOR );
+
+        this._legacyLimit = false;
+    }
+
+    public boolean legacyLimit()
+    {
+        return this._legacyLimit;
+    }
+
+    public void setLegacyLimit( boolean useLegacyLimit )
+    {
+        this._legacyLimit = useLegacyLimit;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/pgsql/PostgreSQLVendorImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/pgsql/PostgreSQLVendorImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/pgsql/PostgreSQLVendorImpl.java
new file mode 100644
index 0000000..e663ed9
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/pgsql/PostgreSQLVendorImpl.java
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.implementation.vendor.pgsql;
+
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ModificationFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.pgsql.PgSQLDataTypeFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.pgsql.PgSQLManipulationFactory;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.pgsql.PgSQLDataTypeFactoryImpl;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.pgsql.PgSQLManipulationFactoryImpl;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.factories.pgsql.PgSQLModificationFactoryImpl;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.pgsql.PostgreSQLProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import 
org.apache.polygene.library.sql.generator.implementation.vendor.DefaultVendor;
+import org.apache.polygene.library.sql.generator.vendor.PostgreSQLVendor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class PostgreSQLVendorImpl extends DefaultVendor
+    implements PostgreSQLVendor
+{
+    protected static final Callback<PgSQLDataTypeFactory> PG_DATA_TYPE_FACTORY 
=
+        new Callback<PgSQLDataTypeFactory>()
+        {
+            public PgSQLDataTypeFactory get( SQLVendor vendor, 
SQLProcessorAggregator processor )
+            {
+                return new PgSQLDataTypeFactoryImpl( (PostgreSQLVendor) 
vendor, processor );
+            }
+        };
+
+    protected static final Callback<PgSQLManipulationFactory> 
PG_MANIPULATION_FACTORY =
+        new Callback<PgSQLManipulationFactory>()
+        {
+            public PgSQLManipulationFactory
+            get( SQLVendor vendor, SQLProcessorAggregator processor )
+            {
+                return new PgSQLManipulationFactoryImpl( (PostgreSQLVendor) 
vendor, processor );
+            }
+        };
+
+    protected static final Callback<ModificationFactory> 
PG_MODIFICATION_FACTORY =
+        new Callback<ModificationFactory>()
+        {
+            public ModificationFactory get( SQLVendor vendor, 
SQLProcessorAggregator processor )
+            {
+                return new PgSQLModificationFactoryImpl( (PostgreSQLVendor) 
vendor, processor );
+            }
+        };
+
+    protected static final ProcessorCallback PG_PROCESSOR = new 
ProcessorCallback()
+    {
+        public SQLProcessorAggregator get( SQLVendor vendor )
+        {
+            return new PostgreSQLProcessor( vendor );
+        }
+    };
+
+    private boolean _legacyOffsetAndLimit;
+
+    public PostgreSQLVendorImpl()
+    {
+        super( PG_PROCESSOR, BOOLEAN_FACTORY, COLUMNS_FACTORY, LITERAL_FACTORY,
+               PG_MODIFICATION_FACTORY, QUERY_FACTORY,
+               TABLE_REFERENCE_FACTORY, DEFINITION_FACTORY, 
PG_MANIPULATION_FACTORY,
+               PG_DATA_TYPE_FACTORY );
+        this._legacyOffsetAndLimit = false;
+    }
+
+    @Override
+    public PgSQLDataTypeFactory getDataTypeFactory()
+    {
+        return (PgSQLDataTypeFactory) super.getDataTypeFactory();
+    }
+
+    @Override
+    public PgSQLManipulationFactory getManipulationFactory()
+    {
+        return (PgSQLManipulationFactory) super.getManipulationFactory();
+    }
+
+    public boolean legacyOffsetAndLimit()
+    {
+        return this._legacyOffsetAndLimit;
+    }
+
+    public void setLegacyOffsetAndLimit( boolean useLegacyOffsetAndLimit )
+    {
+        this._legacyOffsetAndLimit = useLegacyOffsetAndLimit;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/sqlite/SQLiteVendorImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/sqlite/SQLiteVendorImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/sqlite/SQLiteVendorImpl.java
new file mode 100644
index 0000000..e5f5116
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/vendor/sqlite/SQLiteVendorImpl.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.implementation.vendor.sqlite;
+
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.sqlite.SQLiteProcessor;
+import 
org.apache.polygene.library.sql.generator.implementation.vendor.DefaultVendor;
+import org.apache.polygene.library.sql.generator.vendor.SQLVendor;
+import org.apache.polygene.library.sql.generator.vendor.SQLiteVendor;
+
+public class SQLiteVendorImpl extends DefaultVendor
+    implements SQLiteVendor
+{
+
+    protected static final ProcessorCallback SQLITE_PROCESSOR = new 
ProcessorCallback()
+    {
+
+        public SQLProcessorAggregator get( SQLVendor vendor )
+        {
+            return new SQLiteProcessor( vendor );
+        }
+    };
+
+    public SQLiteVendorImpl()
+    {
+        super( SQLITE_PROCESSOR );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/DerbyVendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/DerbyVendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/DerbyVendor.java
new file mode 100644
index 0000000..04c3303
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/DerbyVendor.java
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+public interface DerbyVendor
+    extends SQLVendor
+{
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/H2Vendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/H2Vendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/H2Vendor.java
new file mode 100644
index 0000000..59e8f5a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/H2Vendor.java
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+public interface H2Vendor
+    extends SQLVendor
+{
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/MySQLVendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/MySQLVendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/MySQLVendor.java
new file mode 100644
index 0000000..0cb638c
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/MySQLVendor.java
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+/**
+ * This is vendor for MySQL database. MySQL typically does not understand 
schema-qualified names, so this vendor doesn't
+ * process any schema name it encounters when creating a SQL string.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface MySQLVendor
+    extends SQLVendor
+{
+
+    /**
+     * <p>
+     * Returns whether the legacy LIMIT expression is used instead of the of 
the newer LIMIT/OFFSET. In a legacy syntax,
+     * the {@code LIMIT <n> OFFSET <skip>} is written as {@code LIMIT <skip>, 
<n> } instead. This method is not
+     * thread-safe.
+     * </p>
+     *
+     * @return {@code true} if the legacy LIMIT expressions are used; {@code 
false} otherwise.
+     */
+    boolean legacyLimit();
+
+    /**
+     * <p>
+     * Sets the switch to use legacy LIMIT expression instead of the newer 
LIMIT/OFFSET expressions. In a legacy syntax,
+     * the {@code LIMIT <n> OFFSET <skip>} is written as {@code LIMIT <skip>, 
<n> } instead. Set this to true only if
+     * you really require it. This method is not thread-safe.
+     * </p>
+     *
+     * @param useLegacyLimit Whether to use legacy LIMIT expression instead of 
the newer LIMIT/OFFSET expressions.
+     */
+    void setLegacyLimit( boolean useLegacyLimit );
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/PostgreSQLVendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/PostgreSQLVendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/PostgreSQLVendor.java
new file mode 100644
index 0000000..8d92eca
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/PostgreSQLVendor.java
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+import 
org.apache.polygene.library.sql.generator.grammar.factories.pgsql.PgSQLDataTypeFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.pgsql.PgSQLManipulationFactory;
+
+/**
+ * This is vendor for PostgreSQL database. PostgreSQL provides some extra SQL 
syntax elements for queries (notably
+ * {@code LIMIT} and {@code OFFSET} clauses), and this vendor gives access to 
factory, which enables the creation of
+ * these elements.
+ *
+ * @author Stanislav Muhametsin
+ * @see PgSQLQueryFactory
+ * @see LimitClause
+ * @see OffsetClause
+ */
+public interface PostgreSQLVendor
+    extends SQLVendor
+{
+    /**
+     * Returns the data type factory, which knows to create 
PostgreSQL-specific data types as well as pre-defined
+     * standard ones.
+     */
+    PgSQLDataTypeFactory getDataTypeFactory();
+
+    /**
+     * Returns the manipulation factory, which knows to create 
PostgreSQL-specific data manipulation statements.
+     */
+    PgSQLManipulationFactory getManipulationFactory();
+
+    /**
+     * Returns whether the legacy (pre-8.4) OFFSET/LIMIT expressions are used 
instead of the OFFSET/FETCH defined in the
+     * SQL 2008 standard. For more information, see 
http://www.postgresql.org/docs/8.3/static/sql-select.html#SQL-LIMIT
+     * . This method is not thread-safe.
+     *
+     * @return {@code true} if the legacy OFFSET/LIMIT expressions are used; 
{@code false} otherwise.
+     */
+    boolean legacyOffsetAndLimit();
+
+    /**
+     * Sets the switch to use legacy LIMIT/OFFSET expressions instead of the 
OFFSET/FETCH expressions of the SQL 2008
+     * standard. This is necessary only for pre-8.4 PgSQL databases. For more 
information, see
+     * http://www.postgresql.org/docs/8.3/static/sql-select.html#SQL-LIMIT . 
This method is not thread-safe.
+     *
+     * @param useLegacyOffsetAndLimit Whether to use legacy LIMIT/OFFSET 
expressions instead of the OFFSET/FETCH
+     *                                expressions defined in the SQL 2008 
standard.
+     */
+    void setLegacyOffsetAndLimit( boolean useLegacyOffsetAndLimit );
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendor.java
new file mode 100644
index 0000000..e11da0c
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendor.java
@@ -0,0 +1,137 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.BooleanFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ColumnsFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.DataTypeFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.DefinitionFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.LiteralFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ManipulationFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.ModificationFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.QueryFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.factories.TableReferenceFactory;
+import 
org.apache.polygene.library.sql.generator.grammar.query.QuerySpecification;
+
+/**
+ * This is the base API interface for all SQLVendors to implement. It gives 
the means to acquire factories to create SQL
+ * syntax elements. Additionally, the vendor creates the textual 
representation of these syntax elements so that the
+ * query may be passed directly to database, for example, through JDBC.
+ *
+ * @author Stanislav Muhametsin
+ * @see MySQLVendor
+ * @see PostgreSQLVendor
+ * @see QueryFactory
+ * @see BooleanFactory
+ * @see TableReferenceFactory
+ * @see LiteralFactory
+ * @see ColumnsFactory
+ * @see ModificationFactory
+ * @see #toString(SQLStatement)
+ */
+public interface SQLVendor
+{
+
+    /**
+     * Returns the query factory of this vendor.
+     *
+     * @return The query factory of this vendor.
+     * @see QueryFactory
+     * @see QuerySpecification
+     */
+    QueryFactory getQueryFactory();
+
+    /**
+     * Returns the boolean factory for this vendor.
+     *
+     * @return The boolean factory for this vendor.
+     * @see BooleanFactory
+     */
+    BooleanFactory getBooleanFactory();
+
+    /**
+     * Returns the table reference factory for this vendor.
+     *
+     * @return The table reference factory for this vendor.
+     * @see TableReferenceFactory
+     */
+    TableReferenceFactory getTableReferenceFactory();
+
+    /**
+     * Returns the literal factory for this vendor.
+     *
+     * @return The literal factory for this vendor.
+     * @see LiteralFactory
+     */
+    LiteralFactory getLiteralFactory();
+
+    /**
+     * Returns the columns factory for this vendor.
+     *
+     * @return The columns factory for this vendor.
+     * @see ColumnsFactory
+     */
+    ColumnsFactory getColumnsFactory();
+
+    /**
+     * Returns the factory to create modification statements for this vendor.
+     *
+     * @return The factory to create modification statements for this vendor.
+     * @see ModificationFactory
+     */
+    ModificationFactory getModificationFactory();
+
+    /**
+     * Returns the factory to create definition statements ({@code CREATE 
SCHEMA/TABLE/VIEW/etc}) for this vendor.
+     *
+     * @return The factory to create definition statements for this vendor.
+     * @see DefinitionFactory
+     */
+    DefinitionFactory getDefinitionFactory();
+
+    /**
+     * Returns the factory to create manipulation statements ({@code 
DROP/ALTER SCHEMA/TABLE/etc}) for this vendor.
+     *
+     * @return The factory to create manipulation statements.
+     * @see ManipulationFactory
+     */
+    ManipulationFactory getManipulationFactory();
+
+    /**
+     * Returns the factory to create syntax elements for SQL data types 
compatible with this vendor.
+     *
+     * @return The factory to create syntax elements for SQL data types.
+     * @see DataTypeFactory
+     */
+    DataTypeFactory getDataTypeFactory();
+
+    /**
+     * Takes the {@link SQLStatement} (typically either a query, or a 
modification statement) and produces a textual SQL
+     * statement out of it.
+     *
+     * @param statement The {@link SQLStatement} to process.
+     * @return The textual SQL statement to be used directly with database.
+     * @throws UnsupportedElementException If during parsing this vendor 
encounters some SQL syntax element not
+     *                                     understood by this vendor.
+     * @see SQLStatement
+     */
+    String toString( SQLStatement statement );
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendorProvider.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendorProvider.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendorProvider.java
new file mode 100644
index 0000000..6a91dc9
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLVendorProvider.java
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+import java.io.IOException;
+import java.util.ServiceLoader;
+
+/**
+ * This class provides easy way of acquiring vendors for specific databases.
+ *
+ * @author Stanislav Muhametsin
+ */
+public class SQLVendorProvider
+{
+    /**
+     * <p>
+     * Creates a new vendor. If one passes {@link SQLVendor} as a parameter, 
it will return the default vendor-neutral
+     * implementation.
+     * </p>
+     * <p>
+     * Invoking this statement is equivalent to calling {@code new 
ServiceLoader().firstProvider( vendorClass); }.
+     *
+     * @param <VendorType> The type of the vendor.
+     * @param vendorClass  The class of the vendor.
+     * @return The vendor of a given class.
+     * @throws IOException If {@link ServiceLoader} throws {@link IOException}.
+     * @see ServiceLoader
+     */
+    public static <VendorType extends SQLVendor> VendorType createVendor( 
Class<VendorType> vendorClass )
+        throws IOException
+    {
+        ServiceLoader<VendorType> load = ServiceLoader.load( vendorClass );
+        return load.iterator().next();
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLiteVendor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLiteVendor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLiteVendor.java
new file mode 100644
index 0000000..ba7c961
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/SQLiteVendor.java
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+public interface SQLiteVendor
+    extends SQLVendor
+{
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/UnsupportedElementException.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/UnsupportedElementException.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/UnsupportedElementException.java
new file mode 100644
index 0000000..f07b7a8
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/UnsupportedElementException.java
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.vendor;
+
+import org.apache.polygene.library.sql.generator.grammar.common.SQLStatement;
+
+/**
+ * This exception will typically be thrown by
+ * {@link SQLVendor#toString(SQLStatement)} method when the vendor encounters a
+ * SQL syntax element that the vendor doesn't understand.
+ *
+ * @author Stanislav Muhametsin
+ */
+public class UnsupportedElementException extends RuntimeException
+{
+
+    private static final long serialVersionUID = -5331011803322815958L;
+
+    private final Object _element;
+
+    public UnsupportedElementException( String msg )
+    {
+        this( msg, null );
+    }
+
+    public UnsupportedElementException( String msg, Object element )
+    {
+        super( msg );
+        this._element = element;
+    }
+
+    public Object getElement()
+    {
+        return this._element;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/package-info.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/package-info.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/package-info.java
new file mode 100644
index 0000000..1719927
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/vendor/package-info.java
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+/**
+ * This package provides an API for SQLVendors to implement, and a way to load 
different vendors dynamically. The vendor will give access to factories in 
package org.sql.generation.api.grammar.factories , which will enable users to 
create SQL syntax elements. Vendor is also responsible for creating a textual 
representation (String) of a SQL syntax structure generated with these 
factories.
+ */
+package org.apache.polygene.library.sql.generator.vendor;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.DerbyVendor
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.DerbyVendor
 
b/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.DerbyVendor
new file mode 100644
index 0000000..809d3ec
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.DerbyVendor
@@ -0,0 +1 @@
+org.apache.polygene.library.sql.generator.implementation.vendor.derby.DerbyVendorImpl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.H2Vendor
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.H2Vendor
 
b/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.H2Vendor
new file mode 100644
index 0000000..c2f72bb
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/resources/META-INF/services/org.apache.polygene.library.sql.generator.vendor.H2Vendor
@@ -0,0 +1 @@
+org.apache.polygene.library.sql.generator.implementation.vendor.h2.H2VendorImpl
\ No newline at end of file

Reply via email to