You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/02/19 17:17:12 UTC

[2/3] polygene-java git commit: POLYGENE-225 - Cassandra ES testcases passes now.

POLYGENE-225 - Cassandra ES testcases passes now.


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

Branch: refs/heads/develop
Commit: bd14ba29a67eeeef73c739ad0e7838ec5ff81906
Parents: 3384c1b
Author: niclas <ni...@spicter.com>
Authored: Mon Feb 20 00:53:22 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Mon Feb 20 00:53:22 2017 +0800

----------------------------------------------------------------------
 .../test/entity/AbstractEntityStoreTest.java    |   4 +-
 extensions/entitystore-cassandra/build.gradle   |   1 +
 .../entitystore/cassandra/CassandraCluster.java |  54 +++------
 .../cassandra/CassandraEntityStoreMixin.java    | 120 ++++++++++++-------
 .../cassandra/CassandraEntityStoreService.java  |   3 +
 .../cassandra/CassandraMapEntityStoreTest.java  |   5 +-
 6 files changed, 103 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/bd14ba29/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 a025d26..2fec7df 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
@@ -380,7 +380,7 @@ public abstract class AbstractEntityStoreTest
             UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
             testEntity = unitOfWork.get( testEntity );
             String newVersion = spi.entityStateOf( testEntity ).version();
-            assertThat( "version has changed", newVersion, not( equalTo( version ) ) );
+            assertThat( "version has not changed", newVersion, not( equalTo( version ) ) );
 
             unitOfWork.complete();
         }
@@ -411,7 +411,7 @@ public abstract class AbstractEntityStoreTest
             UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
             testEntity = unitOfWork.get( testEntity );
             String newVersion = spi.entityStateOf( testEntity ).version();
-            assertThat( "version has changed", newVersion, not( equalTo( version ) ) );
+            assertThat( "version has not changed", newVersion, not( equalTo( version ) ) );
 
             unitOfWork.complete();
         }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/bd14ba29/extensions/entitystore-cassandra/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/build.gradle b/extensions/entitystore-cassandra/build.gradle
index 1056b96..6e773c5 100644
--- a/extensions/entitystore-cassandra/build.gradle
+++ b/extensions/entitystore-cassandra/build.gradle
@@ -28,6 +28,7 @@ dependencies {
   compile polygene.core.bootstrap
   compile polygene.library( 'locking' )
   compile libraries.cassandra_client
+  compile libraries.jackson_mapper
 
   runtime polygene.core.runtime
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/bd14ba29/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
index 8672a71..48d0137 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
@@ -17,25 +17,6 @@
  *
  *
  */
-/*
- *  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.cassandra;
 
 import com.datastax.driver.core.AuthProvider;
@@ -44,7 +25,6 @@ import com.datastax.driver.core.KeyspaceMetadata;
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.exceptions.AlreadyExistsException;
-import com.datastax.driver.core.exceptions.InvalidQueryException;
 import org.apache.polygene.api.common.Optional;
 import org.apache.polygene.api.configuration.Configuration;
 import org.apache.polygene.api.injection.scope.Service;
@@ -55,9 +35,6 @@ import org.apache.polygene.spi.entitystore.EntityStoreException;
 @Mixins( CassandraCluster.Mixin.class )
 public interface CassandraCluster
 {
-    String CURRENT_STORAGE_VERSION = "1";
-    String DEFAULT_KEYSPACE_NAME = "polygene";
-    String DEFAULT_TABLE_NAME = "entitystore";
     String IDENTITY_COLUMN = "id";
     String STORE_VERSION_COLUMN = "storeversion";
     String VERSION_COLUMN = "version";
@@ -144,7 +121,7 @@ public interface CassandraCluster
             String tableName = config.entityTableName().get();
             if( tableName == null || tableName.isEmpty() )
             {
-                tableName = DEFAULT_TABLE_NAME;
+                tableName = CassandraEntityStoreService.DEFAULT_TABLE_NAME;
             }
             return tableName;
         }
@@ -158,7 +135,7 @@ public interface CassandraCluster
             keyspaceName = config.keySpace().get();
             if( keyspaceName == null || keyspaceName.isEmpty() )
             {
-                keyspaceName = DEFAULT_KEYSPACE_NAME;
+                keyspaceName = CassandraEntityStoreService.DEFAULT_KEYSPACE_NAME;
             }
             String tableName = tableName();
             KeyspaceMetadata keyspace = cluster.getMetadata().getKeyspace( keyspaceName );
@@ -192,6 +169,7 @@ public interface CassandraCluster
             getEntityStatement = session.prepare( "SELECT "
                                                   + IDENTITY_COLUMN + ", "
                                                   + VERSION_COLUMN + ", "
+                                                  + TYPE_COLUMN + ", "
                                                   + APP_VERSION_COLUMN + ", "
                                                   + STORE_VERSION_COLUMN + ", "
                                                   + LASTMODIFIED_COLUMN + ", "
@@ -211,17 +189,18 @@ public interface CassandraCluster
                                                    + IDENTITY_COLUMN + " = ?" );
 
             updateEntityStatement = session.prepare( "INSERT INTO " + tableName + "( "
-                                                     + IDENTITY_COLUMN + ", "
-                                                     + VERSION_COLUMN + ", "
-                                                     + APP_VERSION_COLUMN + ", "
-                                                     + STORE_VERSION_COLUMN + ", "
-                                                     + LASTMODIFIED_COLUMN + ", "
-                                                     + USECASE_COLUMN + ", "
-                                                     + PROPERTIES_COLUMN + ", "
-                                                     + ASSOCIATIONS_COLUMN + ", "
-                                                     + MANYASSOCIATIONS_COLUMN + ", "
-                                                     + NAMEDASSOCIATIONS_COLUMN
-                                                     + " ) VALUES (?,?,?,'" + CURRENT_STORAGE_VERSION + "',?,?,?,?,?,?)" );
+                                                     + IDENTITY_COLUMN + ", "               // id
+                                                     + VERSION_COLUMN + ", "                // version
+                                                     + TYPE_COLUMN + ", "                   // type
+                                                     + APP_VERSION_COLUMN + ", "            // appversion
+                                                     + STORE_VERSION_COLUMN + ", "          // storeversion
+                                                     + LASTMODIFIED_COLUMN + ", "           // lastmodified
+                                                     + USECASE_COLUMN + ", "                // usecase
+                                                     + PROPERTIES_COLUMN + ", "             // properties
+                                                     + ASSOCIATIONS_COLUMN + ", "           // associations
+                                                     + MANYASSOCIATIONS_COLUMN + ", "       // manyassociations
+                                                     + NAMEDASSOCIATIONS_COLUMN             // namedassociations
+                                                     + " ) VALUES (?,?,?,?,?,?,?,?,?,?,?)" );
         }
 
         private void createPolygeneStateTable( String tableName )
@@ -231,6 +210,7 @@ public interface CassandraCluster
                 session.execute( "CREATE TABLE " + tableName + "(\n"
                                  + "   " + IDENTITY_COLUMN + " text,\n"
                                  + "   " + VERSION_COLUMN + " text,\n"
+                                 + "   " + TYPE_COLUMN + " text,\n"
                                  + "   " + APP_VERSION_COLUMN + " text,\n"
                                  + "   " + STORE_VERSION_COLUMN + " text,\n"
                                  + "   " + LASTMODIFIED_COLUMN + " timestamp,\n"
@@ -239,7 +219,7 @@ public interface CassandraCluster
                                  + "   " + ASSOCIATIONS_COLUMN + " map<text,text>,\n"
                                  + "   " + MANYASSOCIATIONS_COLUMN + " map<text,text>,\n"
                                  + "   " + NAMEDASSOCIATIONS_COLUMN + " map<text,text>,\n"
-                                 + "   PRIMARY KEY (" + IDENTITY_COLUMN + ")\n"
+                                 + "   PRIMARY KEY ( " + IDENTITY_COLUMN + " )\n"
                                  + "   )" );
             }
             catch( AlreadyExistsException e )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/bd14ba29/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
index 798b63b..d757cc5 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
@@ -23,8 +23,7 @@ import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
-import com.datastax.driver.core.TypeTokens;
-import com.google.common.reflect.TypeToken;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Date;
@@ -40,7 +39,6 @@ import org.apache.polygene.api.common.Optional;
 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.Identity;
 import org.apache.polygene.api.identity.IdentityGenerator;
 import org.apache.polygene.api.identity.StringIdentity;
@@ -56,11 +54,13 @@ import org.apache.polygene.api.unitofwork.NoSuchEntityTypeException;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
 import org.apache.polygene.api.usecase.Usecase;
 import org.apache.polygene.api.value.ValueSerialization;
+import org.apache.polygene.api.value.ValueSerializer;
 import org.apache.polygene.spi.entity.EntityState;
 import org.apache.polygene.spi.entity.EntityStatus;
 import org.apache.polygene.spi.entity.ManyAssociationState;
 import org.apache.polygene.spi.entity.NamedAssociationState;
 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;
@@ -79,6 +79,7 @@ import static org.apache.polygene.entitystore.cassandra.CassandraCluster.STORE_V
 import static org.apache.polygene.entitystore.cassandra.CassandraCluster.TYPE_COLUMN;
 import static org.apache.polygene.entitystore.cassandra.CassandraCluster.USECASE_COLUMN;
 import static org.apache.polygene.entitystore.cassandra.CassandraCluster.VERSION_COLUMN;
+import static org.apache.polygene.entitystore.cassandra.CassandraEntityStoreService.CURRENT_STORAGE_VERSION;
 
 /**
  * MongoDB implementation of MapEntityStore.
@@ -87,6 +88,7 @@ public class CassandraEntityStoreMixin
     implements EntityStore, EntityStoreSPI, ServiceActivation
 {
 
+    private static final ValueSerializer.Options MAP_OPTIONS = new ValueSerializer.Options().withMapEntriesAsObjects();
     @This
     private CassandraCluster cluster;
 
@@ -101,7 +103,6 @@ public class CassandraEntityStoreMixin
     @Tagged( ValueSerialization.Formats.JSON )
     private ValueSerialization valueSerialization;
 
-
     @Optional
     @Service
     private IdentityGenerator idGenerator;
@@ -115,14 +116,18 @@ public class CassandraEntityStoreMixin
     @Override
     public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleDescriptor module, EntityReference reference )
     {
-        return queryFor( cluster.entityRetrieveStatement().bind( reference.toURI() ), module, reference  );
+        return queryFor( cluster.entityRetrieveStatement().bind( reference.identity().toString() ), module, reference );
     }
 
     private EntityState queryFor( BoundStatement statement, ModuleDescriptor module, EntityReference reference )
     {
         ResultSet result = cluster.session().execute( statement );
         Row row = result.one();
-        return deserialize( row, module);
+        if( row == null )
+        {
+            throw new EntityNotFoundException( reference );
+        }
+        return deserialize( row, module );
     }
 
     private EntityState deserialize( Row row, ModuleDescriptor module )
@@ -156,12 +161,8 @@ public class CassandraEntityStoreMixin
         }
         Map<String, String> storedProperties = row.getMap( PROPERTIES_COLUMN, String.class, String.class );
         Map<String, String> storedAssociations = row.getMap( ASSOCIATIONS_COLUMN, String.class, String.class );
-
-        TypeToken<String> stringToken = TypeToken.of( String.class );
-        TypeToken<List<String>> listOfStringsToken = TypeTokens.listOf( String.class );
-        TypeToken<Map<String, String>> mapOfStringsToken = TypeTokens.mapOf( String.class, String.class );
-        Map<String, List<String>> storedManyassociation = row.getMap( MANYASSOCIATIONS_COLUMN, stringToken, listOfStringsToken );
-        Map<String, Map<String, String>> storedNamedassociation = row.getMap( NAMEDASSOCIATIONS_COLUMN, stringToken, mapOfStringsToken );
+        Map<String, String> storedManyassociation = row.getMap( MANYASSOCIATIONS_COLUMN, String.class, String.class );
+        Map<String, String> storedNamedassociation = row.getMap( NAMEDASSOCIATIONS_COLUMN, String.class, String.class );
 
         Map<QualifiedName, Object> properties = new HashMap<>();
         entityDescriptor
@@ -176,7 +177,7 @@ public class CassandraEntityStoreMixin
                         storedValue = storedProperties.get( propertyDescriptor.qualifiedName().name() );
                         if( storedValue == null )
                         {
-                            properties.put( propertyDescriptor.qualifiedName(), null );
+                            properties.remove( propertyDescriptor.qualifiedName() );
                         }
                         else
                         {
@@ -226,14 +227,13 @@ public class CassandraEntityStoreMixin
                     List<EntityReference> references = new ArrayList<>();
                     try
                     {
-                        List<String> storedValue = storedManyassociation.get( manyAssociationType.qualifiedName().name() );
+                        String storedValue = storedManyassociation.get( manyAssociationType.qualifiedName().name() );
                         if( storedValue != null )
                         {
-                            for( String value : storedValue )
+                            String[] refs = storedValue.split( "," );
+                            for( String value : refs )
                             {
-                                EntityReference ref = value == null
-                                                      ? null
-                                                      : EntityReference.parseEntityReference( value );
+                                EntityReference ref = EntityReference.parseEntityReference( value );
                                 references.add( ref );
                             }
                             manyAssociations.put( manyAssociationType.qualifiedName(), references );
@@ -256,22 +256,21 @@ public class CassandraEntityStoreMixin
                     Map<String, EntityReference> references = new LinkedHashMap<>();
                     try
                     {
-                        Map<String, String> storedValues = storedNamedassociation.get( namedAssociationType.qualifiedName().name() );
+                        String storedValues = storedNamedassociation.get( namedAssociationType.qualifiedName().name() );
                         if( storedValues != null )
                         {
-                            for( Map.Entry<String, String> entry : storedValues.entrySet() )
+                            Map<String, String> namedRefs = new ObjectMapper().readValue( storedValues, Map.class );
+                            for( Map.Entry<String, String> entry : namedRefs.entrySet() )
                             {
                                 String name = entry.getKey();
                                 String value = entry.getValue();
-                                EntityReference ref = value == null
-                                                      ? null
-                                                      : EntityReference.parseEntityReference( value );
+                                EntityReference ref = EntityReference.parseEntityReference( value );
                                 references.put( name, ref );
                             }
                             namedAssociations.put( namedAssociationType.qualifiedName(), references );
                         }
                     }
-                    catch( RuntimeException e )
+                    catch( Exception e )
                     {
                         // NamedAssociation not found, default to empty one
                         namedAssociations.put( namedAssociationType.qualifiedName(), references );
@@ -294,7 +293,7 @@ public class CassandraEntityStoreMixin
     @Override
     public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference reference )
     {
-        ResultSet result = cluster.session().execute( cluster.entityRetrieveStatement().bind( reference.toURI() ) );
+        ResultSet result = cluster.session().execute( cluster.versionRetrieveStatement().bind( reference.identity().toString() ) );
         Row row = result.one();
         return row.getString( VERSION_COLUMN );
     }
@@ -315,21 +314,50 @@ public class CassandraEntityStoreMixin
                         {
                             Map<String, String> props = new HashMap<>();
                             Map<String, String> assocs = new HashMap<>();
-                            Map<String, List<String>> many = new HashMap<>();
-                            Map<String, Map<String, String>> named = new HashMap<>();
+                            Map<String, String> many = new HashMap<>();
+                            Map<String, String> named = new HashMap<>();
                             serializeProperties( entityState, props );
                             serializeAssociations( entityState, assocs );
                             serializeManyAssociations( entityState, many );
                             serializeNamedAssociations( entityState, named );
-                            Identity identity = (Identity) entityState.propertyValueOf( HasIdentity.IDENTITY_STATE_NAME );
+                            String identity = entityState.entityReference().identity().toString();
                             String ver = entityState.version();
+                            if( entityState.status() == EntityStatus.NEW )
+                            {
+                                ver = "0";
+                            }
+                            else
+                            {
+                                ver = "" + ( Long.parseLong( ver ) + 1 );
+                            }
                             String appVersion = application.version();
-                            Date lastModified = new Date( entityState.lastModified().toEpochMilli() );
-                            String usecase = unitOfWork.usecase().name();
-                            BoundStatement statement = cluster.entityUpdateStatement().bind( identity.toString(), ver, appVersion, lastModified, usecase, props, assocs, many, named );
+                            String type = entityState.entityDescriptor().primaryType().getName();
+                            Usecase usecase = unitOfWork.usecase();
+                            String usecaseName = usecase.name();
+                            Instant lastModified = unitOfWork.currentTime();
+                            BoundStatement statement = cluster.entityUpdateStatement().bind(
+                                identity,
+                                ver,
+                                type,
+                                appVersion,
+                                CURRENT_STORAGE_VERSION,
+                                Date.from( lastModified ),
+                                usecaseName,
+                                props,
+                                assocs,
+                                many,
+                                named );
                             ResultSet result = cluster.session().execute( statement );
                             System.out.println( result );
                         } );
+                String ids = stream( state.spliterator(), false )
+                    .filter( entity -> entity.status() == EntityStatus.REMOVED )
+                    .map( entityState -> "'" + entityState.entityReference().identity().toString() + "'" )
+                    .collect( Collectors.joining( "," ) );
+                if( !ids.isEmpty() )
+                {
+                    cluster.session().execute( "DELETE FROM " + cluster.tableName() + " WHERE id IN (" + ids + ");" );
+                }
             }
 
             private void serializeProperties( EntityState entityState, Map<String, String> props )
@@ -339,8 +367,11 @@ public class CassandraEntityStoreMixin
                     descriptor ->
                     {
                         Object value = entityState.propertyValueOf( descriptor.qualifiedName() );
-                        String serialized = valueSerialization.serialize( value );
-                        props.put( descriptor.qualifiedName().name(), serialized );
+                        if( value != null )
+                        {
+                            String serialized = valueSerialization.serialize( value );
+                            props.put( descriptor.qualifiedName().name(), serialized );
+                        }
                     } );
             }
 
@@ -351,25 +382,28 @@ public class CassandraEntityStoreMixin
                     descriptor ->
                     {
                         EntityReference ref = entityState.associationValueOf( descriptor.qualifiedName() );
-                        assocs.put( descriptor.qualifiedName().name(), ref.toString() );
+                        if( ref != null )
+                        {
+                            assocs.put( descriptor.qualifiedName().name(), ref.toString() );
+                        }
                     } );
             }
 
-            private void serializeManyAssociations( EntityState entityState, Map<String, List<String>> many )
+            private void serializeManyAssociations( EntityState entityState, Map<String, String> many )
             {
-                Stream<? extends AssociationDescriptor> associations = entityState.entityDescriptor().state().associations();
+                Stream<? extends AssociationDescriptor> associations = entityState.entityDescriptor().state().manyAssociations();
                 associations.forEach(
                     descriptor ->
                     {
                         ManyAssociationState references = entityState.manyAssociationValueOf( descriptor.qualifiedName() );
-                        List<String> refs = references.stream().map( EntityReference::toString ).collect( Collectors.toList() );
+                        String refs = references.stream().map( EntityReference::toString ).collect( Collectors.joining( "," ) );
                         many.put( descriptor.qualifiedName().name(), refs );
                     } );
             }
 
-            private void serializeNamedAssociations( EntityState entityState, Map<String, Map<String, String>> named )
+            private void serializeNamedAssociations( EntityState entityState, Map<String, String> named )
             {
-                Stream<? extends AssociationDescriptor> associations = entityState.entityDescriptor().state().associations();
+                Stream<? extends AssociationDescriptor> associations = entityState.entityDescriptor().state().namedAssociations();
                 associations.forEach(
                     descriptor ->
                     {
@@ -379,7 +413,8 @@ public class CassandraEntityStoreMixin
                                       .collect(
                                           Collectors.toMap( Map.Entry::getKey,
                                                             entry -> entry.getValue().toString() ) );
-                        named.put( descriptor.qualifiedName().name(), refs );
+                        String serialized = valueSerialization.serialize( MAP_OPTIONS, refs );
+                        named.put( descriptor.qualifiedName().name(), serialized );
                     } );
             }
 
@@ -400,7 +435,7 @@ public class CassandraEntityStoreMixin
         }
         else
         {
-            newIdentity= idGenerator.generate( UnitOfWork.class );
+            newIdentity = idGenerator.generate( UnitOfWork.class );
         }
         return new DefaultEntityStoreUnitOfWork( module, this, newIdentity, usecase, currentTime );
     }
@@ -413,6 +448,7 @@ public class CassandraEntityStoreMixin
         ResultSet resultSet = session.execute( "SELECT "
                                                + IDENTITY_COLUMN + ", "
                                                + VERSION_COLUMN + ", "
+                                               + TYPE_COLUMN + ", "
                                                + APP_VERSION_COLUMN + ", "
                                                + STORE_VERSION_COLUMN + ", "
                                                + LASTMODIFIED_COLUMN + ", "
@@ -422,7 +458,7 @@ public class CassandraEntityStoreMixin
                                                + MANYASSOCIATIONS_COLUMN + ", "
                                                + NAMEDASSOCIATIONS_COLUMN
                                                + " FROM " + tableName );
-        return stream(resultSet.spliterator(), false).map( row -> deserialize( row, module ));
+        return stream( resultSet.spliterator(), false ).map( row -> deserialize( row, module ) );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/bd14ba29/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
index e7531ce..051c29b 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
@@ -45,4 +45,7 @@ public interface CassandraEntityStoreService
             LockingAbstractComposite,
             Configuration
 {
+    String CURRENT_STORAGE_VERSION = "1";
+    String DEFAULT_KEYSPACE_NAME = "polygene";
+    String DEFAULT_TABLE_NAME = "entitystore";
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/bd14ba29/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
index 3a7464a..0ece039 100644
--- a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
+++ b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
@@ -21,13 +21,13 @@ package org.apache.polygene.entitystore.cassandra;
 
 import org.apache.polygene.entitystore.cassandra.assembly.CassandraDBEntityStoreAssembler;
 import org.apache.polygene.test.entity.CanRemoveAll;
+import org.apache.polygene.valueserialization.jackson.JacksonValueSerializationAssembler;
 import org.junit.BeforeClass;
 import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
 
 import static org.apache.polygene.test.util.Assume.assumeConnectivity;
 
@@ -39,7 +39,6 @@ public class CassandraMapEntityStoreTest
     extends AbstractEntityStoreTest
 {
 
-
     @BeforeClass
     public static void beforeCassandraEntityStoreTests()
     {
@@ -57,7 +56,7 @@ public class CassandraMapEntityStoreTest
         ModuleAssembly config = module.layer().module( "config" );
         new EntityTestAssembler().assemble( config );
         module.services( CassandraEntityStoreService.class ).withTypes( CanRemoveAll.class ).withMixins( EmptyCassandraTableMixin.class );
-        new OrgJsonValueSerializationAssembler().assemble( module );
+        new JacksonValueSerializationAssembler().assemble( module );
 
         // START SNIPPET: assembly
         new CassandraDBEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );