polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [23/33] polygene-java git commit: entitystore-sql is brought in from the es-jooq branch, and fixed it up so that it compiles and passes the standard unit tests using H2. More testing needed for other SQL systems, since there seems to not be consensus on
Date Thu, 26 Oct 2017 07:34:53 GMT
entitystore-sql is brought in from the es-jooq branch, and fixed it up so that it compiles and passes the standard unit tests using H2. More testing needed for other SQL systems, since there seems to not be consensus on how TIME is handled and Jooq is unable to smooth it out completely. Also, the BigDecimal, BigInteger and Float are possibly issues across SQL systems.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/6055b8f7
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/6055b8f7
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/6055b8f7

Branch: refs/heads/develop
Commit: 6055b8f7deccec5f6a7f154b060f08be2f383439
Parents: ad658f6
Author: niclas <niclas@hedhman.org>
Authored: Sun Sep 10 10:35:52 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Sun Sep 10 10:35:52 2017 +0800

----------------------------------------------------------------------
 .../test/entity/AbstractEntityStoreTest.java    |  72 ++--
 dependencies.gradle                             |   8 +-
 extensions/entitystore-jooq/build.gradle        |  44 ---
 extensions/entitystore-jooq/dev-status.xml      |  38 --
 .../entitystore-jooq/src/docs/es-jooq.txt       |  58 ---
 .../entitystore/jooq/AssociationValue.java      |  28 --
 .../polygene/entitystore/jooq/BaseEntity.java   |  34 --
 .../entitystore/jooq/EntitiesTable.java         | 363 ------------------
 .../entitystore/jooq/JooqDslContext.java        |  58 ---
 .../jooq/JooqEntityStoreConfiguration.java      |  73 ----
 .../entitystore/jooq/JooqEntityStoreMixin.java  | 256 -------------
 .../jooq/JooqEntityStoreService.java            |  36 --
 .../polygene/entitystore/jooq/MixinTable.java   | 256 -------------
 .../polygene/entitystore/jooq/SqlTable.java     | 277 --------------
 .../polygene/entitystore/jooq/SqlType.java      | 141 -------
 .../polygene/entitystore/jooq/TableFields.java  |  69 ----
 .../polygene/entitystore/jooq/TypesTable.java   | 189 ----------
 .../jooq/assembly/JooqEntityStoreAssembler.java |  77 ----
 .../entitystore/jooq/JooqEntityStoreTest.java   |  88 -----
 extensions/entitystore-sql/build.gradle         |  44 +++
 extensions/entitystore-sql/dev-status.xml       |  38 ++
 extensions/entitystore-sql/src/docs/es-sql.txt  |  58 +++
 .../entitystore/sql/AssociationValue.java       |  28 ++
 .../polygene/entitystore/sql/BaseEntity.java    |  34 ++
 .../polygene/entitystore/sql/EntitiesTable.java | 363 ++++++++++++++++++
 .../entitystore/sql/JooqDslContext.java         |  58 +++
 .../polygene/entitystore/sql/MixinTable.java    | 256 +++++++++++++
 .../sql/SqlEntityStoreConfiguration.java        |  73 ++++
 .../entitystore/sql/SqlEntityStoreMixin.java    | 367 +++++++++++++++++++
 .../entitystore/sql/SqlEntityStoreService.java  |  36 ++
 .../polygene/entitystore/sql/SqlTable.java      | 271 ++++++++++++++
 .../polygene/entitystore/sql/SqlType.java       | 156 ++++++++
 .../polygene/entitystore/sql/TableFields.java   |  69 ++++
 .../polygene/entitystore/sql/TypesTable.java    | 189 ++++++++++
 .../sql/assembly/SqlEntityStoreAssembler.java   |  77 ++++
 .../entitystore/sql/SqlEntityStoreTest.java     |  88 +++++
 settings.gradle                                 |   2 +-
 37 files changed, 2249 insertions(+), 2123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
index 749bf2e..2812c4e 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
@@ -175,113 +175,119 @@ public abstract class AbstractEntityStoreTest
             instance = unitOfWork.get( instance );
 
             // Check state
-            assertThat( "property 'intValue' has correct value",
+            assertThat( "property 'intValue' has incorrect value",
                         instance.intValue().get(),
                         equalTo( 42 ) );
 
-            assertThat( "property 'longValue' has correct value",
+            assertThat( "property 'longValue' has incorrect value",
                         instance.longValue().get(),
                         equalTo( 42L ) );
 
-            assertThat( "property 'doubleValue' has correct value",
+            assertThat( "property 'doubleValue' has incorrect value",
                         instance.doubleValue().get(),
                         equalTo( 42D ) );
 
-            assertThat( "property 'floatValue' has correct value",
+            assertThat( "property 'floatValue' has incorrect value",
                         instance.floatValue().get(),
                         equalTo( 42F ) );
 
-            assertThat( "property 'booleanValue' has correct value",
+            assertThat( "property 'booleanValue' has incorrect value",
                         instance.booleanValue().get(),
                         equalTo( Boolean.TRUE ) );
 
-            assertThat( "property 'bigInteger' has correct value",
-                        instance.bigIntegerValue().get(),
-                        equalTo( new BigInteger( "42" ) ) );
-
-            assertThat( "property 'bigDecimal' has correct value",
+            assertThat( "property 'bigDecimal' has incorrect value",
                         instance.bigDecimalValue().get(),
                         equalTo( new BigDecimal( "42" ) ) );
 
-            assertThat( "property 'instantValue' has correct value",
-                        instance.instantValue().get(),
-                        equalTo( refDate.toInstant() ) );
+            assertThat( "property 'bigInteger' has incorrect value",
+                        instance.bigIntegerValue().get(),
+                        equalTo( new BigInteger( "42" ) ) );
 
-            assertThat( "property 'dateTimeValue' has correct value",
+            assertThat( "property 'dateTimeValue' has incorrect value",
                         instance.dateTimeValue().get(),
                         equalTo( refDate ) );
 
-            assertThat( "property 'localDateTimeValue' has correct value",
+            assertThat( "property 'instantValue' has incorrect value",
+                        instance.instantValue().get(),
+                        equalTo( refDate.toInstant() ) );
+
+            assertThat( "property 'localDateTimeValue' has incorrect value",
                         instance.localDateTimeValue().get(),
                         equalTo( LocalDateTime.of( 2020, 3, 4, 13, 23, 0 ) ) );
 
-            assertThat( "property 'localDateValue' has correct value",
+            assertThat( "property 'localDateValue' has incorrect value",
                         instance.localDateValue().get(),
                         equalTo( LocalDate.of( 2020, 3, 4 ) ) );
 
-            assertThat( "property 'localTimeValue' has correct value",
+            assertThat( "property 'localTimeValue' has incorrect value",
                         instance.localTimeValue().get(),
                         equalTo( LocalTime.of( 19, 20, 21 ) ) );
 
-            assertThat( "property 'periodValue' has correct value",
+            assertThat( "property 'periodValue' has incorrect value",
                         instance.periodValue().get(),
                         equalTo( Period.of( 1, 1, 2 ) ) );
 
-            assertThat( "property 'durationValue' has correct value",
+            assertThat( "property 'durationValue' has incorrect value",
                         instance.duractionValue().get(),
                         equalTo( Duration.ofSeconds( 3661 ) ) );
 
-            assertThat( "property 'name' has correct value",
+            assertThat( "property 'name' has incorrect value",
                         instance.name().get(),
                         equalTo( "Test" ) );
 
-            assertThat( "property 'unsetName' has correct value",
+            assertThat( "property 'unsetName' has incorrect value",
                         instance.unsetName().get(),
                         equalTo( null ) );
 
-            assertThat( "property 'emptyName' has correct value",
+            assertThat( "property 'emptyName' has incorrect value",
                         instance.emptyName().get(),
                         equalTo( "" ) );
 
-            assertThat( "property 'valueProperty.stringValue' has correct value",
-                        instance.valueProperty().get().valueProperty().get().stringValue().get(),
+            Property<TestValue> testValueProperty = instance.valueProperty();
+            TestValue testValue = testValueProperty.get();
+            Property<TestValue2> testValue2Property = testValue.valueProperty();
+            TestValue2 testValue2 = testValue2Property.get();
+            Property<String> stringProperty = testValue2.stringValue();
+            String actual = stringProperty.get();
+            assertThat( "property 'valueProperty.stringValue' has incorrect value",
+                        actual,
                         equalTo( "Bar" ) );
 
-            assertThat( "property 'valueProperty.listProperty' has correct value",
+            assertThat( "property 'valueProperty.listProperty' has incorrect value",
                         instance.valueProperty().get().listProperty().get().get( 0 ),
                         equalTo( "Foo" ) );
 
-            assertThat( "property 'valueProperty.enumProperty' has correct value",
+            assertThat( "property 'valueProperty.enumProperty' has incorrect value",
                         instance.valueProperty().get().enumProperty().get(),
                         equalTo( TestEnum.VALUE3 ) );
 
-            assertThat( "property 'valueProperty.anotherValue.bling' has correct value",
+            assertThat( "property 'valueProperty.anotherValue.bling' has incorrect value",
                         instance.valueProperty().get().valueProperty().get().anotherValue().get().bling().get(),
                         equalTo( "BlinkLjus" ) );
 
-            assertThat( "property 'valueProperty.tjabbaProperty.bling' has correct value",
+            assertThat( "property 'valueProperty.tjabbaProperty.bling' has incorrect value",
                         instance.valueProperty().get().tjabbaProperty().get().bling().get(),
                         equalTo( "Brakfis" ) );
 
             Map<String, String> mapValue = new HashMap<>();
             mapValue.put( "foo", "bar" );
-            assertThat( "property 'valueProperty.mapStringStringProperty' has correct value",
+            assertThat( "property 'valueProperty.mapStringStringProperty' has incorrect value",
                         instance.valueProperty().get().mapStringStringProperty().get(),
                         equalTo( mapValue ) );
 
-            assertThat( "association has correct value",
+            assertThat( "association has incorrect value",
                         instance.association().get(),
                         equalTo( instance ) );
 
-            assertThat( "manyAssociation has correct value",
+            assertThat( "manyAssociation has incorrect value",
                         instance.manyAssociation().iterator().next(),
                         equalTo( instance ) );
 
-            assertThat( "namedAssociation has correct 'foo' value",
+            assertThat( "namedAssociation has incorrect 'foo' value",
                         instance.namedAssociation().get( "foo" ),
                         equalTo( instance ) );
 
-            assertThat( "namedAssociation has correct 'bar' value",
+            assertThat( "namedAssociation has incorrect 'bar' value",
                         instance.namedAssociation().get( "bar" ),
                         equalTo( instance ) );
         }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/dependencies.gradle
----------------------------------------------------------------------
diff --git a/dependencies.gradle b/dependencies.gradle
index f803793..ff4dd48 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -50,12 +50,12 @@ def commonsDbcpVersion = '2.1.1'
 def commonsLangVersion = '3.6'
 def commonsValidatorVersion = '1.6'
 def derbyVersion = '10.13.1.1'
-def ehcacheVersion = '3.3.1'
-def elasticsearchVersion = '5.5.0'
+def ehcacheVersion = '3.4.0'
+def elasticsearchVersion = '5.5.2'
 def freemarkerVersion = '2.3.26-incubating'
 def geodeVersion = '1.2.0'
 def groovyVersion = '2.4.12'
-def hazelcastVersion = '3.8.3'
+def hazelcastVersion = '3.8.5'
 def httpClientVersion = '4.5.3'
 def jacksonVersion = '2.8.9'
 def jaxbApiVersion = '2.2.12'
@@ -64,7 +64,7 @@ def jdbmVersion = '2.4'
 def jedisVersion = '2.9.0'
 def jettyVersion = '9.2.17.v20160517' // 9.3.x Tests fail!
 def johnzonVersion = '1.1.1'
-def jooqVersion = '3.9.3'
+def jooqVersion = '3.9.5'
 def leveldbVersion = '0.9'
 def leveldbJniVersion = '1.8'
 def liquibaseVersion = '3.5.3'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/build.gradle b/extensions/entitystore-jooq/build.gradle
deleted file mode 100644
index 32ceb70..0000000
--- a/extensions/entitystore-jooq/build.gradle
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *  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.
- *
- *
- */
-
-apply plugin: 'polygene-extension'
-
-description = "Apache Polygene™ ORM EntityStore Extension"
-
-jar { manifest { name = "Apache Polygene™ Extension - EntityStore - ORM" } }
-
-dependencies {
-  api polygene.core.bootstrap
-  api polygene.library( 'sql' )
-  api libraries.jooq
-
-  runtimeOnly polygene.core.runtime
-
-  testImplementation polygene.internals.testsupport
-  testImplementation polygene.library( 'sql-dbcp' )
-  testImplementation libraries.docker_junit
-
-  testRuntimeOnly libraries.logback
-  testRuntimeOnly libraries.derby
-  testRuntimeOnly libraries.h2
-  testRuntimeOnly libraries.mysql_connector
-  testRuntimeOnly libraries.postgres
-  testRuntimeOnly libraries.sqlite
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/dev-status.xml
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/dev-status.xml b/extensions/entitystore-jooq/dev-status.xml
deleted file mode 100644
index b6d4c31..0000000
--- a/extensions/entitystore-jooq/dev-status.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~  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.
-  ~
-  ~
-  -->
-<module xmlns="http://polygene.apache.org/schemas/2008/dev-status/1"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://polygene.apache.org/schemas/2008/dev-status/1
-        http://polygene.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
-  <status>
-        <!--none,early,beta,stable,mature-->
-        <codebase>early</codebase>
-
-        <!-- none, brief, good, complete -->
-        <documentation>brief</documentation>
-
-        <!-- none, some, good, complete -->
-        <unittests>good</unittests>
-    </status>
-    <licenses>
-        <license>ALv2</license>
-    </licenses>
-</module>

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/docs/es-jooq.txt
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/docs/es-jooq.txt b/extensions/entitystore-jooq/src/docs/es-jooq.txt
deleted file mode 100644
index a36d463..0000000
--- a/extensions/entitystore-jooq/src/docs/es-jooq.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-///////////////////////////////////////////////////////////////
- * 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.
-///////////////////////////////////////////////////////////////
-
-[[extension-es-jooq,SQL EntityStore]]
-= ORM EntityStore =
-
-[devstatus]
---------------
-source=extensions/entitystore-jooq/dev-status.xml
---------------
-
-This entitystore is backed by a SQL server, and maps each mixin type of the Composite into separate tables. This is more
-enterprise-friendly, but comes at the cost of less performance compared to the <<extension-es-sql>>.
-
-This extension fully leverage the <<library-sql>> meaning that you must use it to assemble your DataSource and that you
-get <<library-circuitbreaker,Circuit Breaker>> and <<library-jmx, JMX>> integration for free.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-== Assembly ==
-
-Assembly is done using the provided Assembler:
-
-[snippet,java]
-----
-source=extensions/entitystore-jooq/src/test/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreTest.java
-tag=assembly
-----
-
-== Configuration ==
-
-Here are the available configuration properties:
-
-[snippet,java]
-----
-source=extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreConfiguration.java
-tag=config
-----
-
-All authentication related properties are optional.
-By default no authentication is used.
-As soon as you provide a `username`, authentication is set up.

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/AssociationValue.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/AssociationValue.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/AssociationValue.java
deleted file mode 100644
index 528ab8b..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/AssociationValue.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import org.apache.polygene.api.common.QualifiedName;
-
-@SuppressWarnings( "WeakerAccess" )
-public class AssociationValue
-{
-    QualifiedName name;
-    String position;
-    String reference;
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/BaseEntity.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/BaseEntity.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/BaseEntity.java
deleted file mode 100644
index 3c16f16..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/BaseEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import java.time.Instant;
-import org.apache.polygene.api.entity.EntityDescriptor;
-import org.apache.polygene.api.identity.Identity;
-
-@SuppressWarnings( "WeakerAccess" )
-public class BaseEntity
-{
-    EntityDescriptor type;
-    Identity identity;
-    String version;
-    String applicationVersion;
-    Instant modifedAt;
-    Instant createdAt;
-    Identity currentValueIdentity;
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/EntitiesTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/EntitiesTable.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/EntitiesTable.java
deleted file mode 100644
index 001b590..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/EntitiesTable.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import java.lang.reflect.Method;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.polygene.api.association.AssociationDescriptor;
-import org.apache.polygene.api.common.QualifiedName;
-import org.apache.polygene.api.composite.Composite;
-import org.apache.polygene.api.entity.EntityComposite;
-import org.apache.polygene.api.entity.EntityDescriptor;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.identity.HasIdentity;
-import org.apache.polygene.api.identity.StringIdentity;
-import org.apache.polygene.api.property.PropertyDescriptor;
-import org.apache.polygene.api.structure.ModuleDescriptor;
-import org.apache.polygene.api.type.EntityCompositeType;
-import org.apache.polygene.api.unitofwork.NoSuchEntityTypeException;
-import org.apache.polygene.api.util.Classes;
-import org.apache.polygene.spi.entitystore.EntityNotFoundException;
-import org.apache.polygene.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.polygene.spi.entitystore.helpers.DefaultEntityState;
-import org.jooq.Condition;
-import org.jooq.Field;
-import org.jooq.Record;
-import org.jooq.Result;
-import org.jooq.Schema;
-import org.jooq.SelectJoinStep;
-import org.jooq.SelectQuery;
-import org.jooq.Table;
-import org.jooq.impl.DSL;
-
-@SuppressWarnings( "WeakerAccess" )
-public class EntitiesTable
-    implements TableFields
-{
-    private static final Predicate<? super Class<?>> NOT_COMPOSITE = type -> !( type.equals( Composite.class ) || type.equals( EntityComposite.class ) );
-    private static final Predicate<? super Class<?>> NOT_HASIDENTITY = type -> !( type.equals( HasIdentity.class ) );
-    private Map<EntityCompositeType, Set<Class<?>>> mixinTypeCache = new ConcurrentHashMap<>();
-    private Map<Class<?>, MixinTable> mixinTablesCache = new ConcurrentHashMap<>();
-
-    private final Table<Record> entitiesTable;
-    private JooqDslContext dsl;
-    private final TypesTable types;
-    private final Schema schema;
-    private String applicationVersion;
-    private boolean replacementStrategy = false;  // Figure out later if we should support both and if so, how.
-
-    EntitiesTable( JooqDslContext dsl, Schema schema, TypesTable types, String applicationVersion, String entitiesTableName )
-    {
-        this.dsl = dsl;
-        this.types = types;
-        this.schema = schema;
-        this.applicationVersion = applicationVersion;
-        entitiesTable = types.tableOf( entitiesTableName );
-    }
-
-    public BaseEntity fetchEntity( EntityReference reference, ModuleDescriptor module )
-    {
-
-        Result<Record> baseEntityResult = dsl
-            .selectFrom( entitiesTable )
-            .where( identityColumn.eq( reference.identity().toString() ) )
-            .fetch();
-
-        if( baseEntityResult.isEmpty() )
-        {
-            throw new EntityNotFoundException( reference );
-        }
-        Record row = baseEntityResult.get( 0 );
-        return toBaseEntity( row, module );
-    }
-
-    protected BaseEntity toBaseEntity( Record row, ModuleDescriptor module )
-    {
-        BaseEntity result = new BaseEntity();
-        String typeName = row.field( typeNameColumn ).get( row );
-        result.type = findEntityDescriptor( typeName, module );
-        result.version = row.field( versionColumn ).get( row );
-        result.applicationVersion = row.field( applicationVersionColumn ).get( row );
-        result.identity = new StringIdentity( row.field( identityColumn ).get( row ) );
-        result.currentValueIdentity = EntityReference.parseEntityReference( row.field( valueIdentityColumn ).get( row ) ).identity();
-        result.modifedAt = Instant.ofEpochMilli( row.field( modifiedColumn ).get( row ).getTime() );
-        result.createdAt = Instant.ofEpochMilli( row.field( createdColumn ).get( row ).getTime() );
-        return result;
-    }
-
-    public Stream<BaseEntity> fetchAll( EntityDescriptor type, ModuleDescriptor module )
-    {
-        Result<Record> baseEntityResult = dsl
-            .selectFrom( entitiesTable )
-            .fetch();
-        return baseEntityResult.stream().map( record -> toBaseEntity( record, module ) );
-    }
-
-    private EntityDescriptor findEntityDescriptor( String typeName, ModuleDescriptor module )
-    {
-        try
-        {
-            Class<?> type = getClass().getClassLoader().loadClass( typeName );
-            return module.typeLookup().lookupEntityModel( type );
-        }
-        catch( ClassNotFoundException e )
-        {
-            throw new NoSuchEntityTypeException( typeName, module.name(), module.typeLookup() );
-        }
-    }
-
-    void insertEntity( DefaultEntityState state, BaseEntity baseEntity )
-    {
-        EntityCompositeType compositeType = state.entityDescriptor().valueType();
-        Set<Class<?>> mixinTypes = mixinTypeCache.computeIfAbsent( compositeType, createMixinTypesSet( compositeType ) );
-        mixinTypes.forEach( type ->
-                            {
-                                MixinTable table = findMixinTable( type, state.entityDescriptor() );
-                                table.insertMixinState( state, baseEntity.currentValueIdentity.toString() );
-                            } );
-    }
-
-    void modifyEntity( DefaultEntityState state, BaseEntity baseEntity, EntityStoreUnitOfWork uow )
-    {
-        updateBaseEntity( baseEntity, uow );
-        if( replacementStrategy )
-        {
-            insertEntity( state, baseEntity );      // replacement strategy (more safe)
-        }
-        else
-        {
-            EntityCompositeType compositeType = state.entityDescriptor().valueType();
-            Set<Class<?>> mixinTypes = mixinTypeCache.computeIfAbsent( compositeType, createMixinTypesSet( compositeType ) );
-            mixinTypes.forEach( type ->
-                                {
-                                    MixinTable table = findMixinTable( type, state.entityDescriptor() );
-                                    table.modifyMixinState( state, baseEntity.currentValueIdentity.toString() );
-                                } );
-        }
-    }
-
-    private MixinTable findMixinTable( Class<?> type, EntityDescriptor entityDescriptor )
-    {
-        return mixinTablesCache.computeIfAbsent( type, t -> new MixinTable( dsl, schema, types, type, entityDescriptor ) );
-    }
-
-    private Set<Class<?>> mixinsOf( Stream<? extends AssociationDescriptor> stream )
-    {
-        return stream
-            .map( AssociationDescriptor::accessor )
-            .filter( Classes.instanceOf( Method.class ) )
-            .map( accessor -> (Method) accessor )
-            .map( Method::getDeclaringClass )
-            .filter( NOT_HASIDENTITY )
-            .filter( NOT_COMPOSITE )
-            .collect( Collectors.toSet() );
-    }
-
-    private Function<EntityCompositeType, Set<Class<?>>> createMixinTypesSet( EntityCompositeType compositeType )
-    {
-        return type ->
-        {
-            Set<Class<?>> mixins = compositeType
-                .properties()
-                .map( PropertyDescriptor::accessor )
-                .filter( Classes.instanceOf( Method.class ) )
-                .map( accessor -> (Method) accessor )
-                .map( Method::getDeclaringClass )
-                .filter( NOT_HASIDENTITY )
-                .filter( NOT_COMPOSITE )
-                .collect( Collectors.toSet() );
-            Set<Class<?>> mixinsWithAssociations = mixinsOf( compositeType.associations() );
-            Set<Class<?>> mixinsWithManyAssociations = mixinsOf( compositeType.manyAssociations() );
-            Set<Class<?>> mixinsWithNamedAssociations = mixinsOf( compositeType.namedAssociations() );
-            mixins.addAll( mixinsWithAssociations );
-            mixins.addAll( mixinsWithManyAssociations );
-            mixins.addAll( mixinsWithNamedAssociations );
-            return mixins;
-        };
-    }
-
-    void createNewBaseEntity( EntityReference reference, EntityDescriptor descriptor, EntityStoreUnitOfWork uow )
-    {
-        String valueIdentity = UUID.randomUUID().toString();
-        dsl.insertInto( entitiesTable )
-           .set( identityColumn, reference.identity().toString() )
-           .set( createdColumn, new Timestamp( uow.currentTime().toEpochMilli() ) )
-           .set( modifiedColumn, new Timestamp( uow.currentTime().toEpochMilli() ) )
-           .set( valueIdentityColumn, valueIdentity )
-           .set( typeNameColumn, descriptor.primaryType().getName() )
-           .set( versionColumn, "1" )
-           .set( applicationVersionColumn, applicationVersion )
-           .execute();
-    }
-
-    private void updateBaseEntity( BaseEntity entity, EntityStoreUnitOfWork uow )
-    {
-        entity.version = increment( entity.version );
-        if( replacementStrategy )
-        {
-            entity.currentValueIdentity = new StringIdentity( UUID.randomUUID().toString() );
-        }
-        dsl.update( entitiesTable )
-           .set( modifiedColumn, new Timestamp( uow.currentTime().toEpochMilli() ) )
-           .set( valueIdentityColumn, entity.currentValueIdentity.toString() )
-           .set( versionColumn, entity.version )
-           .set( applicationVersionColumn, applicationVersion )
-           .execute();
-    }
-
-    private String increment( String version )
-    {
-        long ver = Long.parseLong( version );
-        return Long.toString( ver + 1 );
-    }
-
-    /**
-     * Builds the SELECT statement for a given entity.
-     * <p>
-     * Example; If we have the following entity
-     * </p>
-     * <code><pre>
-     *     public interface LegalEntity
-     *     {
-     *         Property&lt;String&gt; registration();
-     *     }
-     * <p>
-     *     public interface Person extends LegalEntity
-     *     {
-     *         Property&lt;String&gt; name();
-     * <p>
-     *         &#64;Optional
-     *         Association&lt;Person&gt; spouse();
-     * <p>
-     *         ManyAssocation&lt;Person&gt; children();
-     *     }
-     * </pre></code>
-     * <p>
-     * and we do a simple;
-     * <code><pre>
-     *     Person p = uow.get( Person.class, "niclas" );
-     * </pre></code>
-     * <p>
-     * then the generated query will be
-     * </p>
-     * <code><pre>
-     *     SELECT * FROM ENTITIES
-     *     JOIN Person ON identity = ENTITIES.value_id
-     *     JOIN LegalEntity ON identity = ENTITIES.value_id
-     *     JOIN Person_Assoc ON identity = ENTITIES.value_id
-     *     WHERE ENTITIES.identity = '123'
-     * </pre></code>
-     *
-     * @param entityDescriptor The descriptor of the entity type to be built.
-     * @return The SELECT query that can be executed to retrieve the entity.
-     */
-    public SelectQuery<Record> createGetEntityQuery( EntityDescriptor entityDescriptor, EntityReference reference )
-    {
-        List<Table<Record>> joins = getMixinTables( entityDescriptor );
-        SelectJoinStep<Record> from = dsl.select().from( entitiesTable );
-        for( Table<Record> joinedTable : joins )
-        {
-            Condition joinCondition = valueIdentityColumn.eq( identityColumnOf( joinedTable ) );
-            from = from.leftJoin( joinedTable ).on( joinCondition );
-        }
-        return from.where( identityColumnOf( entitiesTable ).eq( reference.identity().toString() ) ).getQuery();
-    }
-
-    public void fetchAssociations( BaseEntity entity, EntityDescriptor entityDescriptor, Consumer<AssociationValue> consume )
-    {
-        List<Table<Record>> joins = getAssocationsTables( entityDescriptor );
-        SelectJoinStep<Record> from = dsl.select().from( entitiesTable );
-        for( Table<Record> joinedTable : joins )
-        {
-            Condition joinCondition = valueIdentityColumn.eq( identityColumnOf( joinedTable ) );
-            from = from.join( joinedTable ).on( joinCondition );
-        }
-        String reference = entity.identity.toString();
-        SelectQuery<Record> query = from.where( identityColumnOf( entitiesTable ).eq( reference ) ).getQuery();
-        Result<Record> result = query.fetch();
-        result.forEach( record ->
-                        {
-                            AssociationValue value = new AssociationValue();
-                            value.name = QualifiedName.fromClass( entityDescriptor.primaryType(), record.getValue( nameColumn ) );
-                            value.position = record.getValue( indexColumn );
-                            value.reference = record.getValue( referenceColumn );
-                            consume.accept( value );
-                        } );
-    }
-
-    private Field<String> identityColumnOf( Table<Record> joinedTable )
-    {
-        return DSL.field( DSL.name( joinedTable.getName(), identityColumn.getName() ), String.class );
-    }
-
-    public List<Table<Record>> getMixinTables( EntityDescriptor entityDescriptor )
-    {
-        return entityDescriptor
-            .mixinTypes()
-            .filter( NOT_COMPOSITE )
-            .filter( NOT_HASIDENTITY )
-            .map( ( Class<?> type ) -> types.tableFor( type, entityDescriptor ) )
-            .collect( Collectors.toList() );
-    }
-
-    public List<Table<Record>> getAssocationsTables( EntityDescriptor entityDescriptor )
-    {
-        return entityDescriptor
-            .mixinTypes()
-            .filter( NOT_COMPOSITE )
-            .filter( NOT_HASIDENTITY )
-            .map( type -> findMixinTable( type, entityDescriptor ) )
-            .map( MixinTable::associationsTable )
-            .collect( Collectors.toList() );
-    }
-
-    public void removeEntity( EntityReference entityReference, EntityDescriptor descriptor )
-    {
-        ModuleDescriptor module = descriptor.module();
-        BaseEntity baseEntity = fetchEntity( entityReference, module );
-        if( replacementStrategy )
-        {
-            // TODO;  Mark deleted, I guess... not implemented
-        }
-        else
-        {
-            dsl.delete( entitiesTable )
-               .where(
-                   identityColumnOf( entitiesTable ).eq( entityReference.identity().toString() )
-                     )
-               .execute()
-            ;
-            String valueId = baseEntity.currentValueIdentity.toString();
-            List<Table<Record>> mixinTables = getMixinTables( descriptor );
-            List<Table<Record>> assocTables = getAssocationsTables( descriptor );
-            mixinTables.forEach( table -> dsl.delete( table ).where( identityColumnOf( table ).eq( valueId ) ).execute() );
-            assocTables.forEach( table -> dsl.delete( table ).where( identityColumnOf( table ).eq( valueId ) ).execute() );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqDslContext.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqDslContext.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqDslContext.java
deleted file mode 100644
index 95a0fd5..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqDslContext.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import javax.sql.DataSource;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.injection.scope.Uses;
-import org.apache.polygene.api.mixin.Mixins;
-import org.jooq.Configuration;
-import org.jooq.DSLContext;
-import org.jooq.SQLDialect;
-import org.jooq.conf.Settings;
-import org.jooq.impl.DSL;
-import org.jooq.impl.DefaultConfiguration;
-
-@Mixins( JooqDslContext.Mixin.class )
-public interface JooqDslContext extends DSLContext
-{
-
-    class Mixin
-        implements InvocationHandler
-    {
-        private DSLContext dsl;
-
-        public Mixin( @Service DataSource dataSource, @Uses Settings settings, @Uses SQLDialect dialect )
-        {
-            Configuration configuration = new DefaultConfiguration()
-                .set( dataSource )
-                .set( dialect )
-                .set( settings );
-            dsl = DSL.using( configuration );
-        }
-
-        @Override
-        public Object invoke( Object o, Method method, Object[] objects )
-            throws Throwable
-        {
-            return method.invoke( dsl, objects );       // delegate all
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreConfiguration.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreConfiguration.java
deleted file mode 100644
index 7d27cdf..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreConfiguration.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import org.apache.polygene.api.common.UseDefaults;
-import org.apache.polygene.api.property.Property;
-import org.apache.polygene.library.sql.common.SQLConfiguration;
-
-// START SNIPPET: config
-public interface JooqEntityStoreConfiguration extends SQLConfiguration
-{
-    /**
-     * Name of the database schema to use.
-     * Ignored on SQL databases that don't support schemas.
-     */
-    @UseDefaults( "POLYGENE" )
-    @Override
-    Property<String> schemaName();
-
-    /**
-     * Name of the entities table.
-     * <p>
-     * This table contains the Identity and other metadata about each entity instance
-     * </p>
-     */
-    @UseDefaults( "ENTITIES" )
-    Property<String> entitiesTableName();
-
-    /**
-     * Name of the entity types table.
-     * <p>
-     * This table contains the metainfo about each type. Types are versioned according to
-     * application version, to support entity migration over time, and therefor there might
-     * be (but not necessarily) multiple tables for entity types that has evolved beyond
-     * what can be managed within a single table.
-     * </p>
-     */
-    @UseDefaults( "TYPES" )
-    Property<String> typesTableName();
-
-    /**
-     * Defines whether the database schema and table should be created if not already present.
-     */
-    @UseDefaults( "true" )
-    Property<Boolean> createIfMissing();
-
-    /**
-     * The SQL dialect that is being used.
-     * <p>
-     * Typically that is matching a supporting dialect in JOOQ.
-     * See {@link org.jooq.SQLDialect} for supported values.
-     * </p>
-     * @return The property with the dialect value.
-     */
-    @UseDefaults( "" )
-    Property<String> dialect();
-}
-// END SNIPPET: config

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreMixin.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreMixin.java
deleted file mode 100644
index 1daa78b..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreMixin.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-import org.apache.polygene.api.association.AssociationDescriptor;
-import org.apache.polygene.api.association.AssociationStateDescriptor;
-import org.apache.polygene.api.common.QualifiedName;
-import org.apache.polygene.api.entity.EntityDescriptor;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.identity.HasIdentity;
-import org.apache.polygene.api.identity.IdentityGenerator;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.serialization.Serialization;
-import org.apache.polygene.api.structure.ModuleDescriptor;
-import org.apache.polygene.api.usecase.Usecase;
-import org.apache.polygene.spi.entity.EntityState;
-import org.apache.polygene.spi.entity.EntityStatus;
-import org.apache.polygene.spi.entitystore.DefaultEntityStoreUnitOfWork;
-import org.apache.polygene.spi.entitystore.EntityNotFoundException;
-import org.apache.polygene.spi.entitystore.EntityStore;
-import org.apache.polygene.spi.entitystore.EntityStoreSPI;
-import org.apache.polygene.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.polygene.spi.entitystore.StateCommitter;
-import org.apache.polygene.spi.entitystore.helpers.DefaultEntityState;
-import org.jooq.Record;
-import org.jooq.Result;
-import org.jooq.SelectQuery;
-
-import static org.apache.polygene.api.entity.EntityReference.parseEntityReference;
-
-public class JooqEntityStoreMixin
-    implements EntityStore, EntityStoreSPI
-{
-    @This
-    private SqlTable sqlTable;
-
-    @Service
-    private IdentityGenerator identityGenerator;
-
-    @Service
-    private Serialization serialization;
-
-    @Override
-    public EntityState newEntityState( EntityStoreUnitOfWork unitOfWork, EntityReference reference, EntityDescriptor entityDescriptor )
-    {
-        return new DefaultEntityState( unitOfWork.currentTime(), reference, entityDescriptor );
-    }
-
-    @Override
-    public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleDescriptor module, EntityReference reference )
-    {
-        BaseEntity baseEntity = sqlTable.fetchBaseEntity( reference, module );
-        SelectQuery<Record> selectQuery = sqlTable.createGetEntityQuery( baseEntity.type, reference );
-        Result<Record> result = selectQuery.fetch();
-        if( result.isEmpty() )
-        {
-            throw new EntityNotFoundException( reference );
-        }
-        return toEntityState( result, baseEntity, reference );
-    }
-
-    protected EntityState toEntityState( Result<Record> result, BaseEntity baseEntity, EntityReference reference )
-    {
-        AssociationStateDescriptor stateDescriptor = baseEntity.type.state();
-        Map<QualifiedName, Object> properties = new HashMap<>();
-        properties.put( HasIdentity.IDENTITY_STATE_NAME, baseEntity.identity );
-        stateDescriptor.properties()
-                       .filter( prop -> !HasIdentity.IDENTITY_STATE_NAME.equals( prop.qualifiedName() ) )
-                       .forEach( prop ->
-                                 {
-                                     QualifiedName qualifiedName = prop.qualifiedName();
-                                     Object value = result.getValue( 0, qualifiedName.name() );
-                                     properties.put( qualifiedName, value );
-                                 } );
-        Map<QualifiedName, EntityReference> assocations = new HashMap<>();
-        stateDescriptor.associations()
-                       .forEach( assoc ->
-                                 {
-                                     QualifiedName qualifiedName = assoc.qualifiedName();
-                                     String value = (String) result.getValue( 0, qualifiedName.name() );
-                                     if( value != null )
-                                     {
-                                         assocations.put( qualifiedName, parseEntityReference( value ) );
-                                     }
-                                 } );
-        Map<QualifiedName, List<EntityReference>> manyAssocs = new HashMap<>();
-        Map<QualifiedName, Map<String, EntityReference>> namedAssocs = new HashMap<>();
-        sqlTable.fetchAssociations( baseEntity, baseEntity.type, associationValue ->
-        {
-            if( stateDescriptor.hasManyAssociation( associationValue.name ) )
-            {
-                addManyAssociation( stateDescriptor, manyAssocs, associationValue );
-            }
-            else if( stateDescriptor.hasNamedAssociation( associationValue.name ) )
-            {
-                addNamedAssociation( stateDescriptor, namedAssocs, associationValue );
-            }
-        } );
-
-        return new DefaultEntityState( baseEntity.version,
-                                       baseEntity.modifedAt,
-                                       reference,
-                                       EntityStatus.LOADED,
-                                       baseEntity.type,
-                                       properties,
-                                       assocations,
-                                       manyAssocs,
-                                       namedAssocs );
-    }
-
-    private void addNamedAssociation( AssociationStateDescriptor stateDescriptor, Map<QualifiedName, Map<String, EntityReference>> namedAssocs, AssociationValue associationValue )
-    {
-        AssociationDescriptor descriptor = stateDescriptor.getNamedAssociationByName( associationValue.name.name() );
-        QualifiedName qualifiedName = descriptor.qualifiedName();
-        Map<String, EntityReference> map = namedAssocs.computeIfAbsent( qualifiedName, k -> new HashMap<>() );
-        map.put( associationValue.position, parseEntityReference( associationValue.reference ) );
-    }
-
-    private void addManyAssociation( AssociationStateDescriptor stateDescriptor, Map<QualifiedName, List<EntityReference>> manyAssocs, AssociationValue associationValue )
-    {
-        AssociationDescriptor descriptor = stateDescriptor.getManyAssociationByName( associationValue.name.name() );
-        QualifiedName qualifiedName = descriptor.qualifiedName();
-        List<EntityReference> list = manyAssocs.computeIfAbsent( qualifiedName, k -> new ArrayList<>() );
-        String reference = associationValue.reference;
-        list.add( reference == null ? null : parseEntityReference( reference ) );
-    }
-
-    @Override
-    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference reference )
-    {
-        BaseEntity baseEntity = sqlTable.fetchBaseEntity( reference, unitOfWork.module() );
-        return baseEntity.version;
-    }
-
-    @Override
-    public StateCommitter applyChanges( EntityStoreUnitOfWork unitOfWork, Iterable<EntityState> state )
-    {
-        return new JooqStateCommitter( unitOfWork, state, sqlTable.jooqDslContext() );
-    }
-
-    @Override
-    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, Instant currentTime )
-    {
-        return new DefaultEntityStoreUnitOfWork( module,
-                                                 this,
-                                                 identityGenerator.generate( JooqEntityStoreService.class ),
-                                                 usecase,
-                                                 currentTime
-        );
-    }
-
-    @Override
-    public Stream<EntityState> entityStates( ModuleDescriptor module )
-    {
-        Stream<? extends EntityDescriptor> entityTypes = module.entityComposites();
-        return entityTypes
-            .flatMap( type -> sqlTable.fetchAll( type, module ) )
-            .map( baseEntity ->
-                  {
-                      EntityReference reference = EntityReference.entityReferenceFor( baseEntity.identity );
-                      SelectQuery<Record> selectQuery = sqlTable.createGetEntityQuery( baseEntity.type, reference );
-                      Result<Record> result = selectQuery.fetch();
-                      return toEntityState( result, baseEntity, reference );
-                  } );
-    }
-
-    private class JooqStateCommitter
-        implements StateCommitter
-    {
-        private final EntityStoreUnitOfWork unitOfWork;
-        private final Iterable<EntityState> states;
-        private final JooqDslContext dslContext;
-        private final ModuleDescriptor module;
-
-        JooqStateCommitter( EntityStoreUnitOfWork unitOfWork, Iterable<EntityState> states, JooqDslContext dslContext )
-        {
-            this.unitOfWork = unitOfWork;
-            this.states = states;
-            this.dslContext = dslContext;
-            this.module = unitOfWork.module();
-        }
-
-        private void newState( DefaultEntityState state, EntityStoreUnitOfWork unitOfWork )
-        {
-            EntityReference ref = state.entityReference();
-            EntityDescriptor descriptor = state.entityDescriptor();
-            sqlTable.createNewBaseEntity( ref, descriptor, this.unitOfWork );
-            sqlTable.insertEntity( state, sqlTable.fetchBaseEntity( ref, module ), unitOfWork );
-        }
-
-        private void updateState( DefaultEntityState state, EntityStoreUnitOfWork unitOfWork )
-        {
-            EntityDescriptor descriptor = state.entityDescriptor();
-            BaseEntity baseEntity = sqlTable.fetchBaseEntity( state.entityReference(), descriptor.module() );
-            sqlTable.updateEntity( state, baseEntity, unitOfWork );
-        }
-
-        private void removeState( DefaultEntityState state )
-        {
-            EntityReference reference = state.entityReference();
-            EntityDescriptor descriptor = state.entityDescriptor();
-            sqlTable.removeEntity( reference, descriptor );
-        }
-
-        @Override
-        public void commit()
-        {
-            dslContext.transaction( configuration ->
-                                    {
-                                        for( EntityState es : this.states )
-                                        {
-                                            DefaultEntityState state = (DefaultEntityState) es;
-                                            if( state.status() == EntityStatus.NEW )
-                                            {
-                                                newState( state, unitOfWork );
-                                            }
-                                            if( state.status() == EntityStatus.UPDATED )
-                                            {
-                                                updateState( state, unitOfWork );
-                                            }
-                                            if( state.status() == EntityStatus.REMOVED )
-                                            {
-                                                removeState( state );
-                                            }
-                                        }
-                                    } );
-        }
-
-        @Override
-        public void cancel()
-        {
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreService.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreService.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreService.java
deleted file mode 100644
index 511f2f0..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/JooqEntityStoreService.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import org.apache.polygene.api.concern.Concerns;
-import org.apache.polygene.api.configuration.Configuration;
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.spi.entitystore.ConcurrentModificationCheckConcern;
-import org.apache.polygene.spi.entitystore.EntityStateVersions;
-import org.apache.polygene.spi.entitystore.EntityStore;
-import org.apache.polygene.spi.entitystore.StateChangeNotificationConcern;
-
-/**
- * SQL EntityStore service.
- */
-@Concerns( { StateChangeNotificationConcern.class, ConcurrentModificationCheckConcern.class } )
-@Mixins( { JooqEntityStoreMixin.class } )
-public interface JooqEntityStoreService
-    extends EntityStore, EntityStateVersions, Configuration, SqlTable
-{
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/MixinTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/MixinTable.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/MixinTable.java
deleted file mode 100644
index c7b219b..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/MixinTable.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Method;
-import java.sql.Timestamp;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.apache.polygene.api.association.AssociationDescriptor;
-import org.apache.polygene.api.common.QualifiedName;
-import org.apache.polygene.api.entity.EntityDescriptor;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.property.PropertyDescriptor;
-import org.apache.polygene.spi.entity.ManyAssociationState;
-import org.apache.polygene.spi.entity.NamedAssociationState;
-import org.apache.polygene.spi.entitystore.helpers.DefaultEntityState;
-import org.jooq.Field;
-import org.jooq.InsertSetMoreStep;
-import org.jooq.InsertSetStep;
-import org.jooq.Name;
-import org.jooq.Record;
-import org.jooq.Schema;
-import org.jooq.Table;
-import org.jooq.UpdateSetMoreStep;
-import org.jooq.impl.DSL;
-
-class MixinTable
-    implements TableFields
-{
-
-    private final Table<Record> mixinTable;
-    private final Table<Record> mixinAssocsTable;
-
-    private final JooqDslContext dsl;
-    private final Map<QualifiedName, Field<Object>> properties = new ConcurrentHashMap<>();
-    private final Map<QualifiedName, Field<String>> associations = new ConcurrentHashMap<>();
-    private final List<QualifiedName> manyAssociations = new CopyOnWriteArrayList<>();
-    private final List<QualifiedName> namedAssociations = new CopyOnWriteArrayList<>();
-
-    private TypesTable types;
-    private final Class<?> mixinType;
-
-    MixinTable( JooqDslContext dsl, Schema schema, TypesTable types, Class<?> mixinType,
-                EntityDescriptor descriptor )
-    {
-        this.dsl = dsl;
-        this.types = types;
-        this.mixinType = mixinType;
-        mixinTable = types.tableFor( mixinType, descriptor );
-        mixinAssocsTable = getAssocsTable( descriptor, schema );
-
-        descriptor.valueType().properties()
-                  .filter( this::isThisMixin )
-                  .forEach( propDescriptor ->
-                            {
-                                QualifiedName propertyName = propDescriptor.qualifiedName();
-                                Field<Object> propertyField = types.fieldOf( propDescriptor );
-                                properties.put( propertyName, propertyField );
-                            }
-                          );
-
-        descriptor.valueType().associations()
-                  .filter( this::isThisMixin )
-                  .forEach( assocDescriptor ->
-                            {
-                                QualifiedName assocName = assocDescriptor.qualifiedName();
-                                Field<String> assocField = types.fieldOf( assocDescriptor );
-                                associations.put( assocName, assocField );
-                            }
-                          );
-
-        descriptor.valueType().manyAssociations()
-                  .filter( this::isThisMixin )
-                  .forEach( assocDescriptor -> manyAssociations.add( assocDescriptor.qualifiedName() ) );
-
-        descriptor.valueType().namedAssociations()
-                  .filter( this::isThisMixin )
-                  .forEach( assocDescriptor -> namedAssociations.add( assocDescriptor.qualifiedName() ) );
-    }
-
-    void insertMixinState( DefaultEntityState state, String valueIdentity )
-    {
-        InsertSetMoreStep<Record> primaryTable =
-            dsl.insertInto( mixinTable )
-               .set( identityColumn, valueIdentity )
-               .set( createdColumn, new Timestamp( System.currentTimeMillis() ) );
-
-        properties.forEach( ( propertyName, propertyField ) -> primaryTable.set( propertyField, state.propertyValueOf( propertyName ) ) );
-        associations.forEach( ( assocName, assocField ) ->
-                              {
-                                  EntityReference reference = state.associationValueOf( assocName );
-                                  String identity = null;
-                                  if( reference != null )
-                                  {
-                                      identity = reference.identity().toString();
-                                  }
-                                  primaryTable.set( assocField, identity );
-                              }
-                            );
-        int result = primaryTable.execute();
-
-        if( mixinAssocsTable != null )
-        {
-            insertManyAndNamedAssociations( state, valueIdentity );
-        }
-    }
-
-    private void insertManyAndNamedAssociations( DefaultEntityState state, String valueIdentity )
-    {
-        manyAssociations.forEach( assocName ->
-                                  {
-                                      InsertSetStep<Record> assocsTable = dsl.insertInto( mixinAssocsTable );
-                                      ManyAssociationState entityReferences = state.manyAssociationValueOf( assocName );
-                                      int endCount = entityReferences.count();
-                                      int counter = 0;
-                                      for( EntityReference ref : entityReferences )
-                                      {
-                                          InsertSetMoreStep<Record> set = assocsTable.set( identityColumn, valueIdentity )
-                                                                                     .set( nameColumn, assocName.name() )
-                                                                                     .set( indexColumn, "" + counter++ )
-                                                                                     .set( referenceColumn, ref == null ? null : ref.identity().toString() );
-                                          if( ++counter < endCount )
-                                          {
-                                              set.newRecord();
-                                          }
-                                      }
-                                      InsertSetMoreStep<Record> assocs = assocsTable.set( Collections.emptyMap() );
-                                      assocs.execute();
-                                  } );
-
-        namedAssociations.forEach( assocName ->
-                                   {
-                                       InsertSetStep<Record> assocsTable = dsl.insertInto( mixinAssocsTable );
-                                       NamedAssociationState entityReferences = state.namedAssociationValueOf( assocName );
-                                       int count = entityReferences.count();
-                                       for( String name : entityReferences )
-                                       {
-                                           EntityReference ref = entityReferences.get( name );
-                                           InsertSetMoreStep<Record> set = assocsTable.set( identityColumn, valueIdentity )
-                                                                                      .set( nameColumn, assocName.name() )
-                                                                                      .set( indexColumn, name )
-                                                                                      .set( referenceColumn, ref.identity().toString() );
-                                           if( --count > 0 )
-                                           {
-                                               set.newRecord();
-                                           }
-                                       }
-                                       InsertSetMoreStep<Record> assocs = assocsTable.set( Collections.emptyMap() );
-                                       assocs.execute();
-                                   } );
-    }
-
-    Table<Record> associationsTable()
-    {
-        return mixinAssocsTable;
-    }
-
-    private boolean isThisMixin( PropertyDescriptor descriptor )
-    {
-        Class<?> declaringClass = declaredIn( descriptor );
-        return mixinType.equals( declaringClass );
-    }
-
-    private boolean isThisMixin( AssociationDescriptor descriptor )
-    {
-        Class<?> declaringClass = declaredIn( descriptor );
-        return mixinType.equals( declaringClass );
-    }
-
-    private Class<?> declaredIn( PropertyDescriptor descriptor )
-    {
-        AccessibleObject accessor = descriptor.accessor();
-        if( accessor instanceof Method )
-        {
-            return ( (Method) accessor ).getDeclaringClass();
-        }
-        throw new UnsupportedOperationException( "Property declared as " + accessor.getClass() + " is not supported in this Entity Store yet." );
-    }
-
-    private Class<?> declaredIn( AssociationDescriptor descriptor )
-    {
-        AccessibleObject accessor = descriptor.accessor();
-        if( accessor instanceof Method )
-        {
-            return ( (Method) accessor ).getDeclaringClass();
-        }
-        throw new UnsupportedOperationException( "Property declared as " + accessor.getClass() + " is not supported in this Entity Store yet." );
-    }
-
-    void modifyMixinState( DefaultEntityState state, String valueId )
-    {
-        UpdateSetMoreStep<Record> primaryTable =
-            dsl.update( mixinTable )
-               .set( Collections.emptyMap() );  // empty map is a hack to get the right type returned from JOOQ.
-
-        properties.forEach( ( propertyName, propertyField ) -> primaryTable.set( propertyField, state.propertyValueOf( propertyName ) ) );
-        associations.forEach( ( assocName, assocField ) ->
-                              {
-                                  EntityReference reference = state.associationValueOf( assocName );
-                                  primaryTable.set( assocField,
-                                                    reference == null ? null : reference.identity().toString()
-                                                  );
-                              }
-                            );
-        int result = primaryTable.execute();
-
-        if( mixinAssocsTable != null )
-        {
-            // Need to remove existing records.
-            dsl.delete( mixinAssocsTable )
-               .where( identityColumn.eq( valueId ) )
-               .execute();
-            insertManyAndNamedAssociations( state, valueId );
-        }
-    }
-
-    private Table<Record> getAssocsTable( EntityDescriptor descriptor, Schema schema )
-    {
-        if( descriptor.state().manyAssociations().count() > 0
-            || descriptor.state().namedAssociations().count() > 0 )
-        {
-            Name tableName = DSL.name( schema.getName(), mixinTable.getName() + ASSOCS_TABLE_POSTFIX );
-            Table<Record> table = DSL.table( tableName );
-            int result2 = dsl.createTableIfNotExists( table )
-                             .column( identityColumn )
-                             .column( nameColumn )
-                             .column( indexColumn )
-                             .column( referenceColumn )
-                             .execute();
-            return table;
-        }
-        else
-        {
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/6055b8f7/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/SqlTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/SqlTable.java b/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/SqlTable.java
deleted file mode 100644
index 13b6c37..0000000
--- a/extensions/entitystore-jooq/src/main/java/org/apache/polygene/entitystore/jooq/SqlTable.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- *  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.entitystore.jooq;
-
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import javax.sql.DataSource;
-import org.apache.polygene.api.PolygeneAPI;
-import org.apache.polygene.api.composite.TransientBuilderFactory;
-import org.apache.polygene.api.configuration.Configuration;
-import org.apache.polygene.api.entity.EntityDescriptor;
-import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.injection.scope.Structure;
-import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.injection.scope.Uses;
-import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.object.ObjectFactory;
-import org.apache.polygene.api.service.ServiceActivation;
-import org.apache.polygene.api.service.ServiceDescriptor;
-import org.apache.polygene.api.structure.Application;
-import org.apache.polygene.api.structure.ModuleDescriptor;
-import org.apache.polygene.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.polygene.spi.entitystore.helpers.DefaultEntityState;
-import org.jooq.Record;
-import org.jooq.SQLDialect;
-import org.jooq.Schema;
-import org.jooq.SelectQuery;
-import org.jooq.conf.RenderNameStyle;
-import org.jooq.conf.Settings;
-import org.jooq.impl.DSL;
-
-/**
- * This class handles all the Jooq interactions.
- * <p>
- * <p>
- * <p>
- * <h1>Tables</h1>
- * <h2>Types Table</h2>
- * <ul>
- * <li>identity</li>
- * <li>table_name</li>
- * <li>created_at</li>
- * <li>modified_at</li>
- * </ul>
- * <h2>Entities Table</h2>
- * <ul>
- * <li>identity</li>
- * <li>app_version</li>
- * <li>value_id</li>
- * <li>version</li>
- * <li>type</li>
- * <li>modified_at</li>
- * <li>created_at</li>
- * </ul>
- * <h2>Mixin Tables</h2>
- * <p>
- * Each Mixin is stored in its own table. Only the following column is always present;
- * <ul>
- * <li>identity - this is not entity identity but the UUID of the value_id in the Entities Table above.</li>
- * </ul>
- * </p>
- * <p>
- * Each Property of the Mixin (as defined by QualifiedName of the Property, will reside in its own column.
- * All values in columns are (for now) serialized using a ValueSerialization service.
- * </p>
- * <p>
- * Associations also has their own columns in the table, with the EntityReference.identity() stored in them.
- * </p>
- * <p>
- * ManyAssociations and NamedAssociations are stored in a separate table, named &lt;mixintable&gt;_ASSOCS, see below.
- * </p>
- * <h2>Mixin_ASSOCS Table</h2>
- * <ul>
- * <li>identity - the value_id of the mixin value</li>
- * <li>name - the name of the ManyAssociation or NamedAssociation</li>
- * <li>position - for NamedAssociation this is the 'name' (i.e key) and for ManyAssociation this is the index into the list.</li>
- * <li>reference - EntityReference.identity of that association</li>
- * </ul>
- */
-@Mixins( SqlTable.Mixin.class )
-public interface SqlTable extends ServiceActivation
-{
-    BaseEntity fetchBaseEntity( EntityReference reference, ModuleDescriptor module );
-
-    SelectQuery<Record> createGetEntityQuery( EntityDescriptor descriptor, EntityReference reference );
-
-    void fetchAssociations( BaseEntity entity, EntityDescriptor descriptor, Consumer<AssociationValue> consume );
-
-    void createNewBaseEntity( EntityReference ref, EntityDescriptor descriptor, EntityStoreUnitOfWork unitOfWork );
-
-    void insertEntity( DefaultEntityState state, BaseEntity baseEntity, EntityStoreUnitOfWork unitOfWork );
-
-    void updateEntity( DefaultEntityState state, BaseEntity baseEntity, EntityStoreUnitOfWork unitOfWork );
-
-    JooqDslContext jooqDslContext();
-
-    void removeEntity( EntityReference entityReference, EntityDescriptor descriptor );
-
-    Stream<BaseEntity> fetchAll( EntityDescriptor type, ModuleDescriptor module );
-
-    class Mixin
-        implements SqlTable, TableFields, ServiceActivation
-    {
-        @Structure
-        private Application application;
-
-        @Structure
-        private PolygeneAPI api;
-
-        @Structure
-        private TransientBuilderFactory tbf;
-
-        @Structure
-        private ObjectFactory objectFactory;
-
-        @This
-        private Configuration<JooqEntityStoreConfiguration> configuration;
-
-        @Service
-        private DataSource datasource;
-
-        @Uses
-        private ServiceDescriptor serviceDescriptor;
-
-        private EntitiesTable entitiesTable;
-
-        private TypesTable types;
-        private JooqDslContext dsl;
-
-        @Override
-        public BaseEntity fetchBaseEntity( EntityReference reference, ModuleDescriptor module )
-        {
-            return entitiesTable.fetchEntity( reference, module );
-        }
-
-        @Override
-        public Stream<BaseEntity> fetchAll( EntityDescriptor type, ModuleDescriptor module )
-        {
-            return entitiesTable.fetchAll( type, module );
-        }
-
-        @Override
-        public SelectQuery<Record> createGetEntityQuery( EntityDescriptor descriptor, EntityReference reference )
-        {
-            return entitiesTable.createGetEntityQuery( descriptor, reference );
-        }
-
-        @Override
-        public void fetchAssociations( BaseEntity entity, EntityDescriptor descriptor, Consumer<AssociationValue> consume )
-        {
-            entitiesTable.fetchAssociations( entity, descriptor, consume );
-        }
-
-        @Override
-        public void createNewBaseEntity( EntityReference ref, EntityDescriptor descriptor, EntityStoreUnitOfWork unitOfWork )
-        {
-            entitiesTable.createNewBaseEntity( ref, descriptor, unitOfWork );
-        }
-
-        @Override
-        public void insertEntity( DefaultEntityState state, BaseEntity baseEntity, EntityStoreUnitOfWork unitOfWork )
-        {
-            entitiesTable.insertEntity( state, baseEntity );
-        }
-
-        @Override
-        public void updateEntity( DefaultEntityState state, BaseEntity baseEntity, EntityStoreUnitOfWork unitOfWork )
-        {
-            entitiesTable.modifyEntity( state, baseEntity, unitOfWork );
-        }
-
-        @Override
-        public JooqDslContext jooqDslContext()
-        {
-            return dsl;
-        }
-
-        @Override
-        public void removeEntity( EntityReference reference, EntityDescriptor descriptor )
-        {
-            entitiesTable.removeEntity( reference, descriptor );
-        }
-
-        @Override
-        public void activateService()
-            throws Exception
-        {
-            JooqEntityStoreConfiguration config = this.configuration.get();
-            SQLDialect dialect = getSqlDialect( config );
-
-            Settings settings = serviceDescriptor
-                .metaInfo( Settings.class )
-                .withRenderNameStyle( RenderNameStyle.QUOTED );
-            dsl = tbf.newTransient( JooqDslContext.class, settings, dialect );
-
-            String schemaName = config.schemaName().get();
-            String typesTableName = config.typesTableName().get();
-            String entitiesTableName = config.entitiesTableName().get();
-            Schema schema = DSL.schema( DSL.name( schemaName ) );
-            types = new TypesTable( dsl, schema, dialect, typesTableName );
-            entitiesTable = new EntitiesTable( dsl, schema, types, application.version(), entitiesTableName );
-
-            // Eventually create schema
-            if( config.createIfMissing().get() )
-            {
-                if( !dialect.equals( SQLDialect.SQLITE )
-                    && dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase( s.getName() ) ) )
-                {
-                    dsl.createSchema( schema ).execute();
-                }
-
-                dsl.createTableIfNotExists( DSL.name( schemaName, typesTableName ) )
-                   .column( identityColumn )
-                   .column( tableNameColumn )
-                   .column( createdColumn )
-                   .column( modifiedColumn )
-                   .execute();
-
-                dsl.createTableIfNotExists( DSL.name( schemaName, entitiesTableName ) )
-                   .column( identityColumn )
-                   .column( applicationVersionColumn )
-                   .column( valueIdentityColumn )
-                   .column( versionColumn )
-                   .column( typeNameColumn )
-                   .column( modifiedColumn )
-                   .column( createdColumn )
-                   .execute();
-            }
-            datasource.getConnection().commit();
-        }
-
-        @Override
-        public void passivateService()
-            throws Exception
-        {
-
-        }
-
-        private SQLDialect getSqlDialect( JooqEntityStoreConfiguration config )
-        {
-            SQLDialect dialect = null;
-            String dialectString = config.dialect().get();
-            if( dialectString.length() == 0 )
-            {
-                dialect = SQLDialect.DEFAULT;
-            }
-            else
-            {
-                try
-                {
-                    dialect = SQLDialect.valueOf( dialectString );
-                }
-                catch( IllegalArgumentException e )
-                {
-                    throw new IllegalArgumentException( "Invalid SQLDialect: '" + dialectString + "'" );
-                }
-            }
-            return dialect;
-        }
-    }
-}


Mime
View raw message