http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowSubQuery.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowSubQuery.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowSubQuery.java
new file mode 100644
index 0000000..7b1628f
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowSubQuery.java
@@ -0,0 +1,32 @@
+/*
+ *  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.grammar.query;
+
+/**
+ * This syntax element represents subquery in {@code VALUES} expression in 
query.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface RowSubQuery
+    extends RowValueConstructor
+{
+
+    QueryExpression getQueryExpression();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowValueConstructor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowValueConstructor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowValueConstructor.java
new file mode 100644
index 0000000..89827b9
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/RowValueConstructor.java
@@ -0,0 +1,34 @@
+/*
+ *  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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This syntax elements represents either subquery or parenthesized row 
definition of {@code VALUES} expression in
+ * query.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface RowValueConstructor
+    extends Typeable<RowValueConstructor>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SelectColumnClause.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SelectColumnClause.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SelectColumnClause.java
new file mode 100644
index 0000000..1b111e3
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SelectColumnClause.java
@@ -0,0 +1,40 @@
+/*
+ *  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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+import org.apache.polygene.library.sql.generator.grammar.common.SetQuantifier;
+
+/**
+ * This is common interface for columns of {@code SELECT} statement.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SelectColumnClause
+    extends Typeable<SelectColumnClause>
+{
+    /**
+     * Returns the set quantifier for the columns of {@code SELECT} statement.
+     *
+     * @return The set quantifier for the columns of {@code SELECT} statement.
+     * @see SetQuantifier
+     */
+    SetQuantifier getSetQuantifier();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SetOperation.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SetOperation.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SetOperation.java
new file mode 100644
index 0000000..259eec2
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SetOperation.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.grammar.query;
+
+/**
+ * This enum represents the possible set operations to combine queries with. 
These set operations are {@link #UNION},
+ * {@link #INTERSECT}, and {@link #EXCEPT}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public final class SetOperation
+{
+    /**
+     * The {@code UNION} between two queries.
+     */
+    public static final SetOperation UNION = new SetOperation();
+
+    /**
+     * The {@code INTERSECT} between two queries.
+     */
+    public static final SetOperation INTERSECT = new SetOperation();
+
+    /**
+     * The set difference ({@code EXCEPT}) between two queries.
+     */
+    public static final SetOperation EXCEPT = new SetOperation();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SortSpecification.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SortSpecification.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SortSpecification.java
new file mode 100644
index 0000000..2a59780
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/SortSpecification.java
@@ -0,0 +1,46 @@
+/*
+ *  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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+import 
org.apache.polygene.library.sql.generator.grammar.common.ValueExpression;
+
+/**
+ * This syntax element represents the sort specification used in {@code ORDER 
BY} clause.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SortSpecification
+    extends Typeable<SortSpecification>
+{
+    /**
+     * Returns the {@link Ordering} of this sort specification.
+     *
+     * @return The {@link Ordering} of this sort specification.
+     */
+    Ordering getOrderingSpecification();
+
+    /**
+     * The value expression, which may be a column reference, for example.
+     *
+     * @return The value expression of this sort specification.
+     */
+    ValueExpression getValueExpression();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableAlias.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableAlias.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableAlias.java
new file mode 100644
index 0000000..3d85359
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableAlias.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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList;
+
+/**
+ * This syntax element represents the alias for a table. Table alias may have 
additional list of column aliases.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableAlias
+    extends Typeable<TableAlias>
+{
+
+    /**
+     * Returns an alias for a table name.
+     *
+     * @return The alias for the table name.
+     */
+    String getTableAlias();
+
+    /**
+     * Returns aliases for columns in the original table.
+     *
+     * @return Aliases for columns in the original table. May be {@code null}.
+     */
+    ColumnNameList getColumnAliases();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReference.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReference.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReference.java
new file mode 100644
index 0000000..90998a6
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReference.java
@@ -0,0 +1,41 @@
+/*
+ *  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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+import 
org.apache.polygene.library.sql.generator.grammar.query.joins.JoinedTable;
+
+/**
+ * This is common interface for all table references in {@code FROM} clause.
+ *
+ * @author Stanislav Muhametsin
+ * @see FromClause
+ * @see TableReferencePrimary
+ * @see JoinedTable
+ */
+public interface TableReference
+{
+    /**
+     * Helper method to cast this object into {@link Typeable}.
+     *
+     * @return This object.
+     */
+    Typeable<?> asTypeable();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByExpression.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByExpression.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByExpression.java
new file mode 100644
index 0000000..403c7a6
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByExpression.java
@@ -0,0 +1,39 @@
+/*
+ *  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.grammar.query;
+
+/**
+ * This syntax element represents the sub-query which acts as a table in 
{@code FROM} clause.
+ *
+ * @author Stanislav Muhametsin
+ * @see FromClause
+ * @see QueryExpression
+ */
+public interface TableReferenceByExpression
+    extends TableReferencePrimary
+{
+
+    /**
+     * Returns the query to use.
+     *
+     * @return The query to use.
+     */
+    QueryExpression getQuery();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByName.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByName.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByName.java
new file mode 100644
index 0000000..432e982
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferenceByName.java
@@ -0,0 +1,40 @@
+/*
+ *  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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.grammar.common.TableName;
+
+/**
+ * This syntax element represents the reference to a table in {@code FROM} 
clause.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableName
+ */
+public interface TableReferenceByName
+    extends TableReferencePrimary
+{
+    /**
+     * Returns the table name.
+     *
+     * @return The table name.
+     * @see TableName
+     */
+    TableName getTableName();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferencePrimary.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferencePrimary.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferencePrimary.java
new file mode 100644
index 0000000..aa71ad8
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableReferencePrimary.java
@@ -0,0 +1,40 @@
+/*
+ *  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.grammar.query;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is common interface for non-joined table references.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableReferencePrimary
+    extends TableReference, Typeable<TableReferencePrimary>
+{
+
+    /**
+     * Returns the alias for this table.
+     *
+     * @return The alias for this table.
+     * @see TableAlias
+     */
+    TableAlias getTableAlias();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableValueConstructor.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableValueConstructor.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableValueConstructor.java
new file mode 100644
index 0000000..5f5a967
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/TableValueConstructor.java
@@ -0,0 +1,33 @@
+/*
+ *  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.grammar.query;
+
+import java.util.List;
+
+/**
+ * This syntax element represents the {@code VALUES} expression in query.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableValueConstructor
+    extends QueryExpressionBodyActual
+{
+    List<RowValueConstructor> getRows();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/CrossJoinedTable.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/CrossJoinedTable.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/CrossJoinedTable.java
new file mode 100644
index 0000000..2be150a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/CrossJoinedTable.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.grammar.query.joins;
+
+/**
+ * This syntax element represents the cross join ({@code CROSS JOIN} between 
two tables.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface CrossJoinedTable
+    extends JoinedTable
+{
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinCondition.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinCondition.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinCondition.java
new file mode 100644
index 0000000..caab8cb
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinCondition.java
@@ -0,0 +1,39 @@
+/*
+ *  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.grammar.query.joins;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+
+/**
+ * This syntax element represents the join condition, used in {@link 
QualifiedJoinedTable}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface JoinCondition
+    extends JoinSpecification
+{
+
+    /**
+     * Returns the join condition for the {@link QualifiedJoinedTable}.
+     *
+     * @return The join condition for the {@link QualifiedJoinedTable}.
+     */
+    BooleanExpression getSearchConidition();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinSpecification.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinSpecification.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinSpecification.java
new file mode 100644
index 0000000..b13dcc4
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinSpecification.java
@@ -0,0 +1,35 @@
+/*
+ *  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.grammar.query.joins;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is common interface for join specification used in {@link 
QualifiedJoinedTable}.
+ *
+ * @author Stanislav Muhametsin
+ * @see JoinCondition
+ * @see NamedColumnsJoin
+ */
+public interface JoinSpecification
+    extends Typeable<JoinSpecification>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinType.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinType.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinType.java
new file mode 100644
index 0000000..cfbd3ac
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinType.java
@@ -0,0 +1,49 @@
+/*
+ *  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.grammar.query.joins;
+
+/**
+ * This enum represents the join type, used in {@link QualifiedJoinedTable} 
and {@link NaturalJoinedTable}. Is one of
+ * {@link #INNER}, {@link #LEFT_OUTER}, {@link #RIGHT_OUTER}, or {@link 
#FULL_OUTER}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public final class JoinType
+{
+    /**
+     * The {@code INNER} join, typically default.
+     */
+    public static final JoinType INNER = new JoinType();
+
+    /**
+     * The {@code LEFT OUTER} join.
+     */
+    public static final JoinType LEFT_OUTER = new JoinType();
+
+    /**
+     * The {@code RIGHT OUTER} join.
+     */
+    public static final JoinType RIGHT_OUTER = new JoinType();
+
+    /**
+     * The {@code FULL OUTER} join.
+     */
+    public static final JoinType FULL_OUTER = new JoinType();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinedTable.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinedTable.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinedTable.java
new file mode 100644
index 0000000..ddc1300
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/JoinedTable.java
@@ -0,0 +1,50 @@
+/*
+ *  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.grammar.query.joins;
+
+import 
org.apache.polygene.library.sql.generator.grammar.query.QueryExpressionBody;
+import org.apache.polygene.library.sql.generator.grammar.query.TableReference;
+
+/**
+ * This is common interface for joined tables.
+ *
+ * @author Stanislav Muhametsin
+ * @see CrossJoinedTable
+ * @see NaturalJoinedTable
+ * @see QualifiedJoinedTable
+ * @see UnionJoinedTable
+ */
+public interface JoinedTable
+    extends QueryExpressionBody, TableReference
+{
+    /**
+     * Returns the table on the left side of the join.
+     *
+     * @return The table on the left side of the join.
+     */
+    TableReference getLeft();
+
+    /**
+     * Gets the table on the right side of the join.
+     *
+     * @return The table on the right side of the join.
+     */
+    TableReference getRight();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NamedColumnsJoin.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NamedColumnsJoin.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NamedColumnsJoin.java
new file mode 100644
index 0000000..a018ce1
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NamedColumnsJoin.java
@@ -0,0 +1,40 @@
+/*
+ *  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.grammar.query.joins;
+
+import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList;
+
+/**
+ * This syntax element represents the join based on same-named columns in two 
tables having same value. Used in
+ * {@link QualifiedJoinedTable}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NamedColumnsJoin
+    extends JoinSpecification
+{
+
+    /**
+     * Returns the column names. Might be {@code null}.
+     *
+     * @return The column names. Might be {@code null}.
+     */
+    ColumnNameList getColumnNames();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NaturalJoinedTable.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NaturalJoinedTable.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NaturalJoinedTable.java
new file mode 100644
index 0000000..064aba1
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/NaturalJoinedTable.java
@@ -0,0 +1,37 @@
+/*
+ *  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.grammar.query.joins;
+
+/**
+ * This syntax element represents the {@code NATURAL JOIN} between two tables.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface NaturalJoinedTable
+    extends JoinedTable
+{
+
+    /**
+     * Returns the join type for this {@code NATURAL JOIN}.
+     *
+     * @return The join type for this {@code NATURAL JOIN}.
+     */
+    JoinType getJoinType();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/QualifiedJoinedTable.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/QualifiedJoinedTable.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/QualifiedJoinedTable.java
new file mode 100644
index 0000000..6525b4c
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/QualifiedJoinedTable.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.grammar.query.joins;
+
+/**
+ * This syntax element represents the qualified join ({@code JOIN} between two 
tables.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface QualifiedJoinedTable
+    extends JoinedTable
+{
+    /**
+     * Returns the join type for this {@code JOIN}.
+     *
+     * @return The join type for this {@code JOIN}.
+     * @see JoinType
+     */
+    JoinType getJoinType();
+
+    /**
+     * Returns the join specification for this {@code JOIN}.
+     *
+     * @return The join specification for this {@code JOIN}.
+     * @see JoinSpecification
+     */
+    JoinSpecification getJoinSpecification();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/UnionJoinedTable.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/UnionJoinedTable.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/UnionJoinedTable.java
new file mode 100644
index 0000000..c04263e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/UnionJoinedTable.java
@@ -0,0 +1,31 @@
+/*
+ *  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.grammar.query.joins;
+
+/**
+ * This syntax element represents the {@code UNION JOIN} between two tables.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface UnionJoinedTable
+    extends JoinedTable
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/package-info.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/package-info.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/package-info.java
new file mode 100644
index 0000000..4ca3d8b
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/joins/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 syntax interfaces for joined tables, mostly used in 
{@code FROM} clause.
+ */
+package org.apache.polygene.library.sql.generator.grammar.query.joins;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/package-info.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/package-info.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/package-info.java
new file mode 100644
index 0000000..2f30389
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/query/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 and its sub-package contain elements related to SQL queries 
({@code SELECT} statements).
+ */
+package org.apache.polygene.library.sql.generator.grammar.query;
\ No newline at end of file

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/TypeableImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/TypeableImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/TypeableImpl.java
new file mode 100644
index 0000000..70c2e8b
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/TypeableImpl.java
@@ -0,0 +1,104 @@
+/*
+ *  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;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is base class for all classes implementing sub-types of {@link 
Typeable}. It is meant to be extended by actual
+ * domain-specific classes implementing the API interfaces/classes inherited 
from {@link Typeable}. For simple usecases,
+ * typically {@code <ImplementedType>} and {@code <RealImplementedType>} are 
both the same.
+ *
+ * @param <ImplementedType>     The base type for API interface or class.
+ * @param <RealImplementedType> The actual, possibly extended in other 
project, type of API interface or class. This is
+ *                              useful when one has a complex and extendable 
type hierarchy and wants the implementation class to be
+ *                              extendable as well.
+ * @author Stanislav Muhametsin
+ */
+public abstract class TypeableImpl<ImplementedType extends Typeable<?>, 
RealImplementedType extends ImplementedType>
+    implements Typeable<ImplementedType>
+{
+
+    /**
+     * The implemented API type of this object.
+     */
+    private final Class<? extends RealImplementedType> _expressionClass;
+
+    /**
+     * Constructs new base implementation for {@link Typeable}.
+     *
+     * @param realImplementingType The API type, which this specific instance 
implements. Must not be null.
+     * @throws IllegalArgumentException If the {@code realImplementingType} is 
{@code null}.
+     */
+    protected TypeableImpl( Class<? extends RealImplementedType> 
realImplementingType )
+    {
+        if( realImplementingType == null )
+        {
+            throw new IllegalArgumentException( "The implemented type can not 
be null." );
+        }
+
+        this._expressionClass = realImplementingType;
+    }
+
+    /**
+     */
+    public Class<? extends RealImplementedType> getImplementedType()
+    {
+        return this._expressionClass;
+    }
+
+    /**
+     * This {@link Typeable} equals to {@code obj}, when {@code this} == 
{@code obj}, OR when {@code obj} is not null,
+     * and {@code obj} is instance of {@link Typeable}, and this.{@link 
#getImplementedType()} returns SAME type as
+     * {@code obj}. {@link #getImplementedType()}, and {@code this}.{@link 
#doesEqual(Typeable)} returns {@code true}
+     * when given {@code obj}.
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        return this == obj
+               || ( obj != null && obj instanceof Typeable<?>
+                    && this.getImplementedType().equals( ( (Typeable<?>) obj 
).getImplementedType() ) && this
+                        .doesEqual( this._expressionClass.cast( obj ) ) );
+    }
+
+    /**
+     * Override this method to test equaling to other objects implementing 
same API type as this.
+     *
+     * @param another Another object implementing same API type as {@code 
this}. Is guaranteed to be non-null and
+     *                different reference than {@code this}, when called by 
{@link Typeable#equals(Object)}.
+     * @return {@code true} if this object equals to {@code another}; false 
otherwise.
+     */
+    protected abstract boolean doesEqual( RealImplementedType another );
+
+    /**
+     * Helper method to check that either both arguments are {@code null}s, or 
one is non-null and equals to another.
+     * Note that this method fails if {@code one.equals(another)} fails when 
{@code another} is null.
+     *
+     * @param <T>     The type of objects.
+     * @param one     First object to check.
+     * @param another Second object to check.
+     * @return {@code (one == null && another == null) || (one != null && 
one.equals( another ))}.
+     */
+    public static final <T> boolean bothNullOrEquals( T one, T another )
+    {
+        return ( one == null && another == null ) || ( one != null && 
one.equals( another ) );
+    }
+}
\ No newline at end of file

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/grammar/booleans/AbstractBooleanExpression.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/AbstractBooleanExpression.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/AbstractBooleanExpression.java
new file mode 100644
index 0000000..d2485f6
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/AbstractBooleanExpression.java
@@ -0,0 +1,40 @@
+/*
+ *  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.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import 
org.apache.polygene.library.sql.generator.grammar.common.ValueExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.grammar.common.SQLSyntaxElementBase;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public abstract class AbstractBooleanExpression<ExpressionType extends 
BooleanExpression> extends
+                                                                               
           SQLSyntaxElementBase<ValueExpression, ExpressionType>
+    implements BooleanExpression
+{
+
+    protected AbstractBooleanExpression( SQLProcessorAggregator processor,
+                                         Class<? extends ExpressionType> 
expressionClass )
+    {
+        super( processor, expressionClass );
+    }
+}

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/grammar/booleans/BetweenPredicateImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BetweenPredicateImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BetweenPredicateImpl.java
new file mode 100644
index 0000000..e5bdb8e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BetweenPredicateImpl.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.implementation.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BetweenPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class BetweenPredicateImpl extends MultiPredicateImpl<BetweenPredicate>
+    implements BetweenPredicate
+{
+    public BetweenPredicateImpl( SQLProcessorAggregator processor, 
NonBooleanExpression left,
+                                 NonBooleanExpression minimum, 
NonBooleanExpression maximum )
+    {
+        this( processor, BetweenPredicate.class, left, minimum, maximum );
+    }
+
+    protected BetweenPredicateImpl( SQLProcessorAggregator processor, Class<? 
extends BetweenPredicate> predicateClass,
+                                    NonBooleanExpression left, 
NonBooleanExpression minimum, NonBooleanExpression maximum )
+    {
+        super( processor, predicateClass, left, minimum, maximum );
+    }
+
+    public NonBooleanExpression getMaximum()
+    {
+        return this.getRights().get( 1 );
+    }
+
+    public NonBooleanExpression getMinimum()
+    {
+        return this.getRights().get( 0 );
+    }
+}

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/grammar/booleans/BinaryPredicateImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BinaryPredicateImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BinaryPredicateImpl.java
new file mode 100644
index 0000000..af0d1f1
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BinaryPredicateImpl.java
@@ -0,0 +1,65 @@
+/*
+ *  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.grammar.booleans;
+
+import java.util.Objects;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BinaryPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public abstract class BinaryPredicateImpl<ExpressionType extends 
BinaryPredicate> extends
+                                                                               
   AbstractBooleanExpression<ExpressionType>
+    implements BinaryPredicate
+{
+
+    private final NonBooleanExpression _left;
+
+    private final NonBooleanExpression _right;
+
+    protected BinaryPredicateImpl( SQLProcessorAggregator processor, Class<? 
extends ExpressionType> expressionClass,
+                                   NonBooleanExpression left, 
NonBooleanExpression right )
+    {
+        super( processor, expressionClass );
+        Objects.requireNonNull( left, "left" );
+        Objects.requireNonNull( right, "right" );
+
+        this._left = left;
+        this._right = right;
+    }
+
+    public NonBooleanExpression getLeft()
+    {
+        return this._left;
+    }
+
+    public NonBooleanExpression getRight()
+    {
+        return this._right;
+    }
+
+    @Override
+    protected boolean doesEqual( ExpressionType another )
+    {
+        return this._left.equals( another.getLeft() ) && this._right.equals( 
another.getRight() );
+    }
+}

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/grammar/booleans/BooleanTestImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BooleanTestImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BooleanTestImpl.java
new file mode 100644
index 0000000..61cc960
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BooleanTestImpl.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.grammar.booleans;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Objects;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import org.apache.polygene.library.sql.generator.grammar.booleans.BooleanTest;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class BooleanTestImpl extends ComposedBooleanExpressionImpl<BooleanTest>
+    implements BooleanTest
+{
+
+    private final BooleanExpression _booleanExpression;
+    private final TestType _testType;
+    private final TruthValue _truthValue;
+
+    public BooleanTestImpl( SQLProcessorAggregator processor, 
BooleanExpression expression, TestType testType,
+                            TruthValue truthValue )
+    {
+        this( processor, BooleanTest.class, expression, testType, truthValue );
+    }
+
+    protected BooleanTestImpl( SQLProcessorAggregator processor, Class<? 
extends BooleanTest> expressionClass,
+                               BooleanExpression expression, TestType 
testType, TruthValue truthValue )
+    {
+        super( processor, expressionClass );
+
+        Objects.requireNonNull( expression, "expression" );
+
+        if( BooleanUtils.isEmpty( expression ) )
+        {
+            throw new IllegalArgumentException( "Boolean test must be on 
something." );
+        }
+
+        this._booleanExpression = expression;
+        this._testType = testType;
+        this._truthValue = truthValue;
+    }
+
+    public BooleanExpression getBooleanExpression()
+    {
+        return this._booleanExpression;
+    }
+
+    public TestType getTestType()
+    {
+        return this._testType;
+    }
+
+    public TruthValue getTruthValue()
+    {
+        return this._truthValue;
+    }
+
+    public Iterator<BooleanExpression> iterator()
+    {
+        return Arrays.asList( this._booleanExpression ).iterator();
+    }
+}

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/grammar/booleans/BooleanUtils.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BooleanUtils.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BooleanUtils.java
new file mode 100644
index 0000000..a5d797a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/BooleanUtils.java
@@ -0,0 +1,49 @@
+/*
+ *  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.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.ComposedBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.Predicate.EmptyPredicate;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class BooleanUtils
+{
+
+    public static Boolean isEmpty( BooleanExpression expression )
+    {
+        Boolean result = expression == EmptyPredicate.INSTANCE;
+        if( !result && expression instanceof ComposedBooleanExpression )
+        {
+            for( BooleanExpression exp : (ComposedBooleanExpression) 
expression )
+            {
+                result = isEmpty( exp );
+                if( !result )
+                {
+                    break;
+                }
+            }
+        }
+
+        return result;
+    }
+}

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/grammar/booleans/ComposedBooleanExpressionImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ComposedBooleanExpressionImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ComposedBooleanExpressionImpl.java
new file mode 100644
index 0000000..bb00466
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ComposedBooleanExpressionImpl.java
@@ -0,0 +1,54 @@
+/*
+ *  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.grammar.booleans;
+
+import java.util.Iterator;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.ComposedBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public abstract class ComposedBooleanExpressionImpl<ExpressionType extends 
ComposedBooleanExpression> extends
+                                                                               
                       AbstractBooleanExpression<ExpressionType>
+    implements ComposedBooleanExpression
+{
+
+    protected ComposedBooleanExpressionImpl( SQLProcessorAggregator processor,
+                                             Class<? extends ExpressionType> 
expressionClass )
+    {
+        super( processor, expressionClass );
+    }
+
+    @Override
+    protected boolean doesEqual( ExpressionType another )
+    {
+        Iterator<BooleanExpression> thisIter = this.iterator();
+        Iterator<BooleanExpression> anotherIter = another.iterator();
+        Boolean prevResult = true;
+        while( thisIter.hasNext() && anotherIter.hasNext() && prevResult )
+        {
+            prevResult = thisIter.next().equals( anotherIter.next() );
+        }
+
+        return !thisIter.hasNext() && !anotherIter.hasNext() && prevResult;
+    }
+}

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/grammar/booleans/ConjunctionImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ConjunctionImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ConjunctionImpl.java
new file mode 100644
index 0000000..d96f6d1
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ConjunctionImpl.java
@@ -0,0 +1,70 @@
+/*
+ *  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.grammar.booleans;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Objects;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import org.apache.polygene.library.sql.generator.grammar.booleans.Conjunction;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class ConjunctionImpl extends ComposedBooleanExpressionImpl<Conjunction>
+    implements Conjunction
+{
+
+    private final BooleanExpression _left;
+
+    private final BooleanExpression _right;
+
+    public ConjunctionImpl( SQLProcessorAggregator processor, 
BooleanExpression left, BooleanExpression right )
+    {
+        this( processor, Conjunction.class, left, right );
+    }
+
+    protected ConjunctionImpl( SQLProcessorAggregator processor, Class<? 
extends Conjunction> expressionClass,
+                               BooleanExpression left, BooleanExpression right 
)
+    {
+        super( processor, expressionClass );
+        Objects.requireNonNull( left, "left" );
+        Objects.requireNonNull( right, "right" );
+
+        this._left = left;
+        this._right = right;
+    }
+
+    public BooleanExpression getLeft()
+    {
+        return this._left;
+    }
+
+    public BooleanExpression getRight()
+    {
+        return this._right;
+    }
+
+    public Iterator<BooleanExpression> iterator()
+    {
+        return Arrays.asList( this._left, this._right ).iterator();
+    }
+}

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/grammar/booleans/DisjunctionImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/DisjunctionImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/DisjunctionImpl.java
new file mode 100644
index 0000000..c8e507f
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/DisjunctionImpl.java
@@ -0,0 +1,70 @@
+/*
+ *  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.grammar.booleans;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Objects;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+import org.apache.polygene.library.sql.generator.grammar.booleans.Disjunction;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class DisjunctionImpl extends ComposedBooleanExpressionImpl<Disjunction>
+    implements Disjunction
+{
+
+    private final BooleanExpression _left;
+
+    private final BooleanExpression _right;
+
+    public DisjunctionImpl( SQLProcessorAggregator processor, 
BooleanExpression left, BooleanExpression right )
+    {
+        this( processor, Disjunction.class, left, right );
+    }
+
+    protected DisjunctionImpl( SQLProcessorAggregator processor, Class<? 
extends Disjunction> expressionClass,
+                               BooleanExpression left, BooleanExpression right 
)
+    {
+        super( processor, expressionClass );
+        Objects.requireNonNull( left, "left" );
+        Objects.requireNonNull( right, "right" );
+
+        this._left = left;
+        this._right = right;
+    }
+
+    public BooleanExpression getLeft()
+    {
+        return this._left;
+    }
+
+    public BooleanExpression getRight()
+    {
+        return this._right;
+    }
+
+    public Iterator<BooleanExpression> iterator()
+    {
+        return Arrays.asList( this._left, this._right ).iterator();
+    }
+}

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/grammar/booleans/EqualsPredicateImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/EqualsPredicateImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/EqualsPredicateImpl.java
new file mode 100644
index 0000000..7668478
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/EqualsPredicateImpl.java
@@ -0,0 +1,43 @@
+/*
+ *  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.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.EqualsPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class EqualsPredicateImpl extends BinaryPredicateImpl<EqualsPredicate>
+    implements EqualsPredicate
+{
+
+    public EqualsPredicateImpl( SQLProcessorAggregator processor, 
NonBooleanExpression left, NonBooleanExpression right )
+    {
+        this( processor, EqualsPredicate.class, left, right );
+    }
+
+    protected EqualsPredicateImpl( SQLProcessorAggregator processor, Class<? 
extends EqualsPredicate> predicateClass,
+                                   NonBooleanExpression left, 
NonBooleanExpression right )
+    {
+        super( processor, predicateClass, left, right );
+    }
+}

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/grammar/booleans/ExistsPredicateImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ExistsPredicateImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ExistsPredicateImpl.java
new file mode 100644
index 0000000..44c1623
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/ExistsPredicateImpl.java
@@ -0,0 +1,49 @@
+/*
+ *  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.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.ExistsPredicate;
+import org.apache.polygene.library.sql.generator.grammar.query.QueryExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class ExistsPredicateImpl extends UnaryPredicateImpl<ExistsPredicate>
+    implements ExistsPredicate
+{
+
+    public ExistsPredicateImpl( SQLProcessorAggregator processor, 
QueryExpression query )
+    {
+        this( processor, ExistsPredicate.class, query );
+    }
+
+    protected ExistsPredicateImpl( SQLProcessorAggregator processor, Class<? 
extends ExistsPredicate> predicateClass,
+                                   QueryExpression query )
+    {
+        super( processor, predicateClass, query );
+    }
+
+    @Override
+    public QueryExpression getValueExpression()
+    {
+        return (QueryExpression) super.getValueExpression();
+    }
+}

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/grammar/booleans/GreaterOrEqualPredicateImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/GreaterOrEqualPredicateImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/GreaterOrEqualPredicateImpl.java
new file mode 100644
index 0000000..8b8f582
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/GreaterOrEqualPredicateImpl.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.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.GreaterOrEqualPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class GreaterOrEqualPredicateImpl extends 
BinaryPredicateImpl<GreaterOrEqualPredicate>
+    implements GreaterOrEqualPredicate
+{
+
+    public GreaterOrEqualPredicateImpl( SQLProcessorAggregator processor, 
NonBooleanExpression left,
+                                        NonBooleanExpression right )
+    {
+        this( processor, GreaterOrEqualPredicate.class, left, right );
+    }
+
+    protected GreaterOrEqualPredicateImpl( SQLProcessorAggregator processor,
+                                           Class<? extends 
GreaterOrEqualPredicate> predicateClass, NonBooleanExpression left, 
NonBooleanExpression right )
+    {
+        super( processor, predicateClass, left, right );
+    }
+}

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/grammar/booleans/GreaterThanPredicateImpl.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/GreaterThanPredicateImpl.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/GreaterThanPredicateImpl.java
new file mode 100644
index 0000000..3fa3b62
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/implementation/grammar/booleans/GreaterThanPredicateImpl.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.grammar.booleans;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.GreaterThanPredicate;
+import 
org.apache.polygene.library.sql.generator.grammar.common.NonBooleanExpression;
+import 
org.apache.polygene.library.sql.generator.implementation.transformation.spi.SQLProcessorAggregator;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public class GreaterThanPredicateImpl extends 
BinaryPredicateImpl<GreaterThanPredicate>
+    implements GreaterThanPredicate
+{
+
+    public GreaterThanPredicateImpl( SQLProcessorAggregator processor, 
NonBooleanExpression left,
+                                     NonBooleanExpression right )
+    {
+        this( processor, GreaterThanPredicate.class, left, right );
+    }
+
+    protected GreaterThanPredicateImpl( SQLProcessorAggregator processor,
+                                        Class<? extends GreaterThanPredicate> 
predicateClass, NonBooleanExpression left, NonBooleanExpression right )
+    {
+        super( processor, predicateClass, left, right );
+    }
+}

Reply via email to