You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/09/09 17:07:35 UTC

[03/13] ISIS-522: mothballing SQL OS.

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcMoneyValueMapper.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcMoneyValueMapper.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcMoneyValueMapper.java
new file mode 100755
index 0000000..1821795
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcMoneyValueMapper.java
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.applib.PersistFailedException;
+import org.apache.isis.applib.value.Money;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.mapping.FieldMapping;
+import org.apache.isis.objectstore.sql.mapping.FieldMappingFactory;
+
+/**
+ * Money needs to implement a two-column persistence, 1 for amount, 1 for
+ * 3-digit currency
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JdbcMoneyValueMapper extends AbstractJdbcMultiFieldMapping {
+
+    public static class Factory implements FieldMappingFactory {
+        private final String type1;
+        private final String type2;
+
+        public Factory(final String type1, final String type2) {
+            this.type1 = type1;
+            this.type2 = type2;
+        }
+
+        @Override
+        public FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field) {
+            return new JdbcMoneyValueMapper(field, type1, type2);
+        }
+    }
+
+    public JdbcMoneyValueMapper(final ObjectAssociation field, final String type1, final String type2) {
+        super(field, 2, type1, type2);
+    }
+
+    @Override
+    protected Object preparedStatementObject(final int index, final Object o) {
+
+        if (o instanceof Money) {
+            if (index == 0) {
+                return ((Money) o).doubleValue();
+            } else {
+                return ((Money) o).getCurrency();
+            }
+        } else {
+            throw new PersistFailedException("Invalid object type " + o.getClass().getCanonicalName() + " for MoneyValueMapper");
+        }
+    }
+
+    @Override
+    protected Object getObjectFromResults(final Results results) {
+        final double doubleValue = results.getDouble(columnName(0));
+        final String currencyValue = results.getString(columnName(1));
+
+        final Money moneyObject = new Money(doubleValue, currencyValue);
+
+        return moneyObject;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceFieldMapping.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceFieldMapping.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceFieldMapping.java
new file mode 100644
index 0000000..db826c4
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceFieldMapping.java
@@ -0,0 +1,101 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.objectstore.sql.AbstractFieldMappingFactory;
+import org.apache.isis.objectstore.sql.DatabaseConnector;
+import org.apache.isis.objectstore.sql.Defaults;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.Sql;
+import org.apache.isis.objectstore.sql.mapping.FieldMapping;
+
+public class JdbcObjectReferenceFieldMapping extends JdbcObjectReferenceMapping implements FieldMapping {
+
+    public static class Factory extends AbstractFieldMappingFactory {
+        @Override
+        public FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field) {
+            if (field.getSpecification().isAbstract()) {
+                final String dataType = getTypeOverride(object, field, Defaults.TYPE_LONG_STRING());
+                return new JdbcAbstractReferenceFieldMapping(field, dataType);
+            }
+            return new JdbcObjectReferenceFieldMapping(field);
+        }
+    }
+
+    protected final ObjectAssociation field;
+
+    @Override
+    public ObjectAssociation getField() {
+        return field;
+    }
+
+    @Override
+    public void appendWhereClause(final DatabaseConnector connector, final StringBuffer sql, final ObjectAdapter object) {
+        final ObjectAdapter fieldValue = field.get(object);
+        final RootOid oid = (RootOid) fieldValue.getOid();
+        appendWhereClause(connector, sql, oid);
+    }
+
+    @Override
+    public void appendWhereObject(final DatabaseConnector connector, final ObjectAdapter objectAdapter) {
+        final ObjectAdapter fieldValue = field.get(objectAdapter);
+        final RootOid oid = (RootOid) fieldValue.getOid();
+        connector.addToQueryValues(primaryKey(oid));
+    }
+
+    public JdbcObjectReferenceFieldMapping(final ObjectAssociation field) {
+        super(columnName(field), field.getSpecification());
+        this.field = field;
+    }
+
+    private static String columnName(final ObjectAssociation field) {
+        return Sql.sqlFieldName(field.getId());
+    }
+
+    @Override
+    public void appendInsertValues(final DatabaseConnector connector, final StringBuffer sb, final ObjectAdapter object) {
+        final ObjectAdapter fieldValue = field.get(object);
+        super.appendInsertValues(connector, sb, fieldValue);
+    }
+
+    @Override
+    public void appendUpdateValues(final DatabaseConnector connector, final StringBuffer sql, final ObjectAdapter object) {
+        final ObjectAdapter fieldValue = field.get(object);
+        super.appendUpdateValues(connector, sql, fieldValue);
+    }
+
+    @Override
+    public void initializeField(final ObjectAdapter object, final Results rs) {
+        final ObjectAdapter reference = initializeField(rs);
+        ((OneToOneAssociation) field).initAssociation(object, reference);
+    }
+
+    @Override
+    public void debugData(final DebugBuilder debug) {
+        debug.appendln(field.getId(), getColumn());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMapping.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMapping.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMapping.java
new file mode 100644
index 0000000..95a02b5
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMapping.java
@@ -0,0 +1,68 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.objectstore.sql.DatabaseConnector;
+import org.apache.isis.objectstore.sql.IdMappingAbstract;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.Sql;
+import org.apache.isis.objectstore.sql.SqlObjectStoreException;
+import org.apache.isis.objectstore.sql.mapping.ObjectReferenceMapping;
+
+public class JdbcObjectReferenceMapping extends IdMappingAbstract implements ObjectReferenceMapping {
+    private final ObjectSpecification specification;
+
+    public JdbcObjectReferenceMapping(final String columnName, final ObjectSpecification specification) {
+        this.specification = specification;
+        final String idColumn = Sql.sqlName("fk_" + columnName);
+        setColumn(idColumn);
+    }
+
+    @Override
+    public void appendUpdateValues(final DatabaseConnector connector, final StringBuffer sql, final ObjectAdapter adapter) {
+        sql.append(getColumn());
+        if (adapter == null) {
+            sql.append("= NULL ");
+        } else {
+            sql.append("= ?");
+            // sql.append(primaryKey(object.getOid()));
+            final RootOid oid = (RootOid) adapter.getOid();
+            connector.addToQueryValues(primaryKey(oid));
+        }
+    }
+
+    public ObjectAdapter initializeField(final Results rs) {
+        final Oid oid = recreateOid(rs, specification);
+        if (oid != null) {
+            if (specification.isAbstract()) {
+                throw new SqlObjectStoreException("NOT DEALING WITH POLYMORPHIC ASSOCIATIONS");
+            } else {
+                return getAdapter(specification, oid);
+            }
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMappingFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMappingFactory.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMappingFactory.java
new file mode 100644
index 0000000..e2e1d23
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcObjectReferenceMappingFactory.java
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.objectstore.sql.mapping.ObjectReferenceMapping;
+import org.apache.isis.objectstore.sql.mapping.ObjectReferenceMappingFactory;
+
+public class JdbcObjectReferenceMappingFactory implements ObjectReferenceMappingFactory {
+
+    @Override
+    public ObjectReferenceMapping createReferenceMapping(final String columnName, final ObjectSpecification specification) {
+        return new JdbcObjectReferenceMapping(columnName, specification);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPasswordValueMapper.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPasswordValueMapper.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPasswordValueMapper.java
new file mode 100644
index 0000000..0c2bd4e
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPasswordValueMapper.java
@@ -0,0 +1,106 @@
+/**
+ *  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.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.applib.value.Password;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.objectstore.sql.AbstractFieldMappingFactory;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.jdbc.helpers.SimplePasswordEncoderDecoder;
+import org.apache.isis.objectstore.sql.mapping.FieldMapping;
+
+/**
+ * Implements a Password string type that stores the passwords with a simple encoding in the database.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JdbcPasswordValueMapper extends AbstractJdbcFieldMapping {
+
+    public static class Factory extends AbstractFieldMappingFactory {
+        private final String type;
+        private final String passwordSeed;
+        private final Integer encLength;
+
+        public Factory(final String type, final String passwordSeed, final Integer encLength) {
+            super();
+            this.type = type;
+            this.passwordSeed = passwordSeed;
+            this.encLength = encLength;
+        }
+
+        @Override
+        public FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field) {
+            final String dataType = getTypeOverride(object, field, type);
+            return new JdbcPasswordValueMapper(field, dataType, passwordSeed, encLength);
+        }
+    }
+
+    private final String type;
+
+    private final SimplePasswordEncoderDecoder simplePasswordEncoderDecoder;
+
+    public JdbcPasswordValueMapper(final ObjectAssociation field, final String type, final String passwordSeed,
+        final Integer encLength) {
+        super(field);
+        this.type = type;
+
+        simplePasswordEncoderDecoder = new SimplePasswordEncoderDecoder(passwordSeed, encLength);
+    }
+
+    /*
+     * @see org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.AbstractJdbcFieldMapping#columnType()
+     */
+    @Override
+    protected String columnType() {
+        return type;
+    }
+
+    /*
+     * @see
+     * org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.AbstractJdbcFieldMapping#preparedStatementObject(org.apache
+     * .isis.core.metamodel.adapter.ObjectAdapter)
+     */
+    @Override
+    protected Object preparedStatementObject(ObjectAdapter value) {
+        if (value == null) {
+            return null;
+        }
+        final Object o = value.getObject();
+        final String rawPassword = ((Password) o).getPassword();
+        return simplePasswordEncoderDecoder.encodeRawValueIntoEncodedString(rawPassword);
+    }
+
+    /*
+     * @see
+     * org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.AbstractJdbcFieldMapping#setFromDBColumn(org.apache.isis.
+     * runtimes.dflt.objectstores.sql.Results, java.lang.String,
+     * org.apache.isis.core.metamodel.spec.feature.ObjectAssociation)
+     */
+    @Override
+    protected ObjectAdapter setFromDBColumn(Results results, String columnName, ObjectAssociation field) {
+        final String encodedValue = results.getString(columnName);
+        if (encodedValue == null) {
+            return null;
+        }
+        final EncodableFacet facet = field.getSpecification().getFacet(EncodableFacet.class);
+        return facet.fromEncodedString(simplePasswordEncoderDecoder.decodeEncodedValueIntoRawString(encodedValue));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPolymorphicObjectReferenceMapping.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPolymorphicObjectReferenceMapping.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPolymorphicObjectReferenceMapping.java
new file mode 100755
index 0000000..cf6c419
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcPolymorphicObjectReferenceMapping.java
@@ -0,0 +1,71 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.objectstore.sql.DatabaseConnector;
+import org.apache.isis.objectstore.sql.IdMappingAbstract;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.Sql;
+import org.apache.isis.objectstore.sql.SqlObjectStoreException;
+import org.apache.isis.objectstore.sql.mapping.ObjectReferenceMapping;
+
+public class JdbcPolymorphicObjectReferenceMapping extends IdMappingAbstract implements ObjectReferenceMapping {
+    private ObjectSpecification specification;
+
+    public JdbcPolymorphicObjectReferenceMapping(final String columnName) {
+        final String idColumn = Sql.sqlName(columnName);
+        setColumn(idColumn);
+    }
+
+    public void setObjectSpecification(final ObjectSpecification specification) {
+        this.specification = specification;
+    }
+
+    @Override
+    public void appendUpdateValues(final DatabaseConnector connector, final StringBuffer sql, final ObjectAdapter adapter) {
+        sql.append(getColumn());
+        if (adapter == null) {
+            sql.append("= NULL ");
+        } else {
+            sql.append("= ?");
+            // sql.append(primaryKey(object.getOid()));
+            final RootOid oid = (RootOid) adapter.getOid();
+            connector.addToQueryValues(primaryKey(oid));
+        }
+    }
+
+    public ObjectAdapter initializeField(final Results rs) {
+        final Oid oid = recreateOid(rs, specification);
+        if (oid != null) {
+            if (specification.isAbstract()) {
+                throw new SqlObjectStoreException("NOT DEALING WITH POLYMORPHIC ASSOCIATIONS");
+            } else {
+                return getAdapter(specification, oid);
+            }
+        } else {
+            return null;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcResults.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcResults.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcResults.java
new file mode 100644
index 0000000..8fb81a8
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcResults.java
@@ -0,0 +1,232 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import java.io.InputStream;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Calendar;
+import java.util.HashMap;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+import org.apache.isis.applib.value.Date;
+import org.apache.isis.applib.value.Time;
+import org.apache.isis.objectstore.sql.Defaults;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.SqlObjectStoreException;
+
+public class JdbcResults implements Results {
+    ResultSet set;
+
+    public JdbcResults(final CallableStatement statement) {
+    }
+
+    public JdbcResults(final ResultSet set) {
+        this.set = set;
+    }
+
+    @Override
+    public void close() {
+        try {
+            set.close();
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public int getInt(final String columnName) {
+        try {
+            return set.getInt(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public long getLong(final String columnName) {
+        try {
+            return set.getLong(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public String getString(final String columnName) {
+        try {
+            return set.getString(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public boolean next() {
+        try {
+            return set.next();
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public java.sql.Date getJavaDateOnly(final String columnName) {
+        try {
+            // 2010-03-05 = 1267747200000
+            // 2010-04-08 = 1270684800000
+            // This is really painful! Java refuses to create java.util.Date in
+            // UTC!
+            // It creates java.util.Dates in Local time-zone, but assumes the DB
+            // date is UTC.
+            final String string = set.getString(columnName);
+            final DateTime utcDate = new DateTime(string, Defaults.getTimeZone());
+            final java.sql.Date date = new java.sql.Date(utcDate.getMillis());
+            return date;
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public java.sql.Time getJavaTimeOnly(final String columnName) {
+        try {
+            final String string = set.getString(columnName);
+
+            final DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss");
+
+            final DateTime utcDate = formatter.withZone(Defaults.getTimeZone()).parseDateTime(string);
+            final java.sql.Time time = new java.sql.Time(utcDate.getMillis());
+
+            return time;
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public java.util.Date getJavaDateTime(final String columnName, final Calendar calendar) {
+        try {
+            return set.getDate(columnName, calendar);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Object getObject(final String columnName) {
+        try {
+            return set.getObject(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Date getDate(final String columnName) {
+        try {
+            // 2010-03-05 = 1267747200000
+            // 2010-04-08 = 1270684800000
+            // This is really painful! Java refuses to create java.util.Date in
+            // UTC!
+            // It creates java.util.Dates in Local time-zone, but assumes the DB
+            // date is UTC.
+            final String string = set.getString(columnName);
+            final DateTime utcDate = new DateTime(string, Defaults.getTimeZone());
+            return new Date(utcDate);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Time getTime(final String columnName) {
+        try {
+            final String string = set.getString(columnName);
+            final DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss");
+            final DateTimeZone defaultTimeZone = Defaults.getTimeZone();
+            final DateTime utcDate = formatter.withZone(defaultTimeZone).parseDateTime(string);
+            return new Time(utcDate);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public double getDouble(final String columnName) {
+        try {
+            return set.getDouble(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Object getAsType(final String columnName, final Class<?> clazz) {
+        try {
+            final HashMap<String, Class<?>> map = new HashMap<String, Class<?>>();
+            map.put("FLOAT", float.class);
+            return set.getObject(columnName, map);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Float getFloat(final String columnName) {
+        try {
+            return set.getFloat(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Short getShort(final String columnName) {
+        try {
+            return set.getShort(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public Boolean getBoolean(final String columnName) {
+        try {
+            return set.getBoolean(columnName);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+
+    @Override
+    public InputStream getStream(String column) {
+        try {
+            return set.getBinaryStream(column);
+        } catch (final SQLException e) {
+            throw new SqlObjectStoreException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcSqlMetaData.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcSqlMetaData.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcSqlMetaData.java
new file mode 100644
index 0000000..0efd9fe
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcSqlMetaData.java
@@ -0,0 +1,86 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+
+import org.apache.isis.objectstore.sql.SqlMetaData;
+
+public class JdbcSqlMetaData implements SqlMetaData {
+
+    private final boolean hasQuoteString;
+    private final String quoteString;
+    private final String keywords;
+    private final String timeDateFunctions;
+    private final boolean storesLowerCaseIdentifiers;
+    private final boolean storesMixedCaseIdentifiers;
+    private final boolean storesUpperCaseIdentifiers;
+
+    public JdbcSqlMetaData(final DatabaseMetaData metaData) throws SQLException {
+        keywords = metaData.getSQLKeywords();
+        timeDateFunctions = metaData.getTimeDateFunctions();
+        quoteString = metaData.getIdentifierQuoteString();
+        hasQuoteString = (quoteString != " ");
+        storesLowerCaseIdentifiers = metaData.storesLowerCaseIdentifiers();
+        storesMixedCaseIdentifiers = metaData.storesMixedCaseIdentifiers();
+        storesUpperCaseIdentifiers = metaData.storesUpperCaseIdentifiers();
+
+    }
+
+    @Override
+    public String getKeywords() {
+        return keywords;
+    }
+
+    @Override
+    public String getTimeDateFunctions() {
+        return timeDateFunctions;
+    }
+
+    @Override
+    public String getQuoteString() {
+        return quoteString;
+    }
+
+    @Override
+    public boolean isStoresLowerCaseIdentifiers() {
+        return storesLowerCaseIdentifiers;
+    }
+
+    @Override
+    public boolean isStoresMixedCaseIdentifiers() {
+        return storesMixedCaseIdentifiers;
+    }
+
+    @Override
+    public boolean isStoresUpperCaseIdentifiers() {
+        return storesUpperCaseIdentifiers;
+    }
+
+    @Override
+    public String quoteIdentifier(final String identifier) {
+        if (hasQuoteString) {
+            return quoteString + identifier + quoteString;
+        } else {
+            return identifier;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimeMapper.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimeMapper.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimeMapper.java
new file mode 100644
index 0000000..3b76abc
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimeMapper.java
@@ -0,0 +1,84 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.applib.PersistFailedException;
+import org.apache.isis.applib.value.Time;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.sql.AbstractFieldMappingFactory;
+import org.apache.isis.objectstore.sql.Defaults;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.mapping.FieldMapping;
+
+public class JdbcTimeMapper extends AbstractJdbcFieldMapping {
+
+    private final String dataType;
+
+    public static class Factory extends AbstractFieldMappingFactory {
+
+        @Override
+        public FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field) {
+            final String dataType = getTypeOverride(object, field, Defaults.TYPE_TIME());
+            return new JdbcTimeMapper(field, dataType);
+        }
+    }
+
+    protected JdbcTimeMapper(final ObjectAssociation field, final String dataType) {
+        super(field);
+        this.dataType = dataType;
+    }
+
+    @Override
+    protected Object preparedStatementObject(final ObjectAdapter value) {
+        final Time asTime = (Time) value.getObject();
+        return asTime.asJavaTime();
+    }
+
+    @Override
+    public ObjectAdapter setFromDBColumn(final Results results, final String columnName, final ObjectAssociation field) {
+        /*
+         * Long hour = Long.decode(encodedValue.substring(0, 2)); Long minute =
+         * Long.decode(encodedValue.substring(3, 5)); Long millis = (minute +
+         * hour * 60) * 60 * 1000; String valueString = "T" +
+         * Long.toString(millis); return
+         * field.getSpecification().getFacet(EncodableFacet.class)
+         * .fromEncodedString(valueString);
+         */
+        ObjectAdapter restoredValue;
+        final Class<?> correspondingClass = field.getSpecification().getCorrespondingClass();
+        if (correspondingClass == Time.class) {
+            final Time timeValue = results.getTime(columnName);
+            restoredValue = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(timeValue);
+        } else {
+            throw new PersistFailedException("Unhandled time type: " + correspondingClass.getCanonicalName());
+        }
+        return restoredValue;
+
+    }
+
+    @Override
+    public String columnType() {
+        return dataType;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimestampMapper.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimestampMapper.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimestampMapper.java
new file mode 100644
index 0000000..73e6906
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/JdbcTimestampMapper.java
@@ -0,0 +1,78 @@
+/*
+ *  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.isis.objectstore.sql.jdbc;
+
+import org.apache.isis.applib.PersistFailedException;
+import org.apache.isis.applib.value.TimeStamp;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.sql.AbstractFieldMappingFactory;
+import org.apache.isis.objectstore.sql.Defaults;
+import org.apache.isis.objectstore.sql.Results;
+import org.apache.isis.objectstore.sql.mapping.FieldMapping;
+
+public class JdbcTimestampMapper extends AbstractJdbcFieldMapping {
+
+    private final String dataType;
+
+    public static class Factory extends AbstractFieldMappingFactory {
+
+        @Override
+        public FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field) {
+            final String dataType = getTypeOverride(object, field, Defaults.TYPE_TIMESTAMP());
+            return new JdbcTimestampMapper(field, dataType);
+        }
+    }
+
+    protected JdbcTimestampMapper(final ObjectAssociation field, final String dataType) {
+        super(field);
+        this.dataType = dataType;
+    }
+
+    @Override
+    protected Object preparedStatementObject(final ObjectAdapter value) {
+        final TimeStamp asDate = (TimeStamp) value.getObject();
+        final java.sql.Timestamp timeStamp = new java.sql.Timestamp(asDate.longValue());
+        return timeStamp;
+    }
+
+    @Override
+    public ObjectAdapter setFromDBColumn(final Results results, final String columnName, final ObjectAssociation field) {
+
+        ObjectAdapter restoredValue;
+        final Class<?> correspondingClass = field.getSpecification().getCorrespondingClass();
+        if (correspondingClass == TimeStamp.class) {
+            final java.sql.Timestamp o = (java.sql.Timestamp) results.getObject(columnName);
+            final TimeStamp timeValue = new TimeStamp(o.getTime());
+            restoredValue = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(timeValue);
+        } else {
+            throw new PersistFailedException("Unhandled time type: " + correspondingClass.getCanonicalName());
+        }
+        return restoredValue;
+    }
+
+    @Override
+    public String columnType() {
+        return dataType;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoder.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoder.java
new file mode 100644
index 0000000..8f6c797
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoder.java
@@ -0,0 +1,115 @@
+/**
+ *  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.isis.objectstore.sql.jdbc.helpers;
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class SimplePasswordEncoderDecoder {
+    private final String passwordSeed;
+    private final int seedLength;
+    private final Integer valueOfZero = Integer.valueOf('0');
+    private final int dbLength;
+
+    public SimplePasswordEncoderDecoder(String passwordSeed, Integer encLength) {
+        this.passwordSeed = passwordSeed;
+        if (passwordSeed == null) {
+            seedLength = 0;
+        } else {
+            seedLength = passwordSeed.length();
+        }
+        dbLength = encLength;
+    }
+
+    /**
+     * Use a simple algorithm to encode the given value into an encoded String
+     * 
+     * @param String
+     *            raw value
+     * @return encoded String
+     */
+    public final String encodeRawValueIntoEncodedString(final String value) {
+        if (passwordSeed == null) {
+            return value;
+        }
+        final int rawLength = value.length();
+        String length = Integer.toHexString(rawLength);
+        if (length.length() == 1) {
+            length = "0" + length;
+        }
+        String encodePart1 = length + value;
+        String encoded = "";
+        for (int i = 0; i < rawLength + 2; i++) {
+            int thisSeed = passwordSeed.charAt(i % seedLength);
+            int thisPassword = encodePart1.charAt(i);
+            int nextValue = (thisSeed + thisPassword) % 255;
+            encoded = encoded.concat(String.format("%2h", nextValue));
+
+        }
+        for (int i = rawLength; i < (dbLength / 2) - 2; i++) {
+            int thisSeed = passwordSeed.charAt(i % seedLength);
+            int thisPassword = passwordSeed.charAt((i - 2) % seedLength);
+            int nextValue = (thisSeed + thisPassword + i) % 255;
+            encoded = encoded.concat(String.format("%2h", nextValue));
+        }
+
+        return encoded;
+    }
+
+    /**
+     * Use a simple algorithm to decode the given encoded String into a raw String
+     * 
+     * @param String
+     *            encoded value
+     * @return decoded raw String
+     */
+    public final String decodeEncodedValueIntoRawString(final String encodedValue) {
+        if (passwordSeed == null) {
+            return encodedValue;
+        }
+        int passwordLength = extractIndexedValueAsInt(encodedValue, 0);
+
+        String decodedValue = "";
+        for (int i = 0; i < passwordLength; i++) {
+            char extracted = extractIndexedValueAsChar(encodedValue, i + 2);
+            decodedValue = decodedValue + (extracted);
+        }
+        return decodedValue;
+    }
+
+    private int extractIndexedValueAsInt(final String encodedValue, int index) {
+        int value1 = decodeIndexedValue(encodedValue, index) - valueOfZero;
+        int value2 = decodeIndexedValue(encodedValue, index + 1) - valueOfZero;
+        return value1 * 16 + value2;
+    }
+
+    private char extractIndexedValueAsChar(final String encodedValue, int index) {
+        int value1 = decodeIndexedValue(encodedValue, index);
+        return (char) value1;
+    }
+
+    private int decodeIndexedValue(final String encodedValue, int index) {
+        String s = encodedValue.substring((index) * 2, (index) * 2 + 2);
+        int hex = Integer.valueOf(s, 16);
+        int thisSeed = passwordSeed.charAt(index % seedLength);
+        int passwordValue = hex - thisSeed;
+        return passwordValue;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java
new file mode 100644
index 0000000..62391bf
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java
@@ -0,0 +1,93 @@
+/*
+ *  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.isis.objectstore.sql.jdbc.installer;
+
+import org.apache.isis.applib.value.Color;
+import org.apache.isis.applib.value.Date;
+import org.apache.isis.applib.value.DateTime;
+import org.apache.isis.applib.value.Image;
+import org.apache.isis.applib.value.Money;
+import org.apache.isis.applib.value.Password;
+import org.apache.isis.applib.value.Percentage;
+import org.apache.isis.applib.value.Time;
+import org.apache.isis.applib.value.TimeStamp;
+import org.apache.isis.objectstore.sql.Defaults;
+import org.apache.isis.objectstore.sql.FieldMappingFactoryInstaller;
+import org.apache.isis.objectstore.sql.FieldMappingLookup;
+import org.apache.isis.objectstore.sql.jdbc.JdbcBinaryValueMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcColorValueMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcDateMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcDateTimeMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcGeneralValueMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcImageValueMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcMoneyValueMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcObjectReferenceFieldMapping;
+import org.apache.isis.objectstore.sql.jdbc.JdbcObjectReferenceMappingFactory;
+import org.apache.isis.objectstore.sql.jdbc.JdbcPasswordValueMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcTimeMapper;
+import org.apache.isis.objectstore.sql.jdbc.JdbcTimestampMapper;
+
+public class JdbcFieldMappingFactoryInstaller implements FieldMappingFactoryInstaller {
+
+    @Override
+    public void load(final FieldMappingLookup lookup) {
+
+        lookup.addFieldMappingFactory(Image.class,
+            new JdbcImageValueMapper.Factory(Defaults.TYPE_STRING(), Defaults.TYPE_BLOB()));
+
+        lookup.addFieldMappingFactory(Boolean.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_BOOLEAN()));
+        lookup.addFieldMappingFactory(Short.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_SHORT()));
+        lookup.addFieldMappingFactory(Integer.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_INT()));
+        lookup.addFieldMappingFactory(Long.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_LONG()));
+        lookup.addFieldMappingFactory(Float.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_FLOAT()));
+        lookup.addFieldMappingFactory(Double.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_DOUBLE()));
+        lookup.addFieldMappingFactory(char.class, new JdbcGeneralValueMapper.Factory("CHAR(2)"));
+
+        lookup.addFieldMappingFactory(Money.class, new JdbcMoneyValueMapper.Factory("FLOAT", "VARCHAR(3)"));
+        lookup.addFieldMappingFactory(Percentage.class, new JdbcGeneralValueMapper.Factory("FLOAT"));
+        lookup.addFieldMappingFactory(Password.class, new JdbcPasswordValueMapper.Factory(Defaults.TYPE_PASSWORD(),
+            Defaults.PASSWORD_SEED(), Defaults.PASSWORD_ENC_LENGTH()));
+        lookup.addFieldMappingFactory(Color.class, new JdbcColorValueMapper.Factory(Defaults.TYPE_LONG()));
+        lookup.addFieldMappingFactory(String.class, new JdbcGeneralValueMapper.Factory(Defaults.TYPE_STRING()));
+
+        lookup.addFieldMappingFactory(Date.class, new JdbcDateMapper.Factory());
+        lookup.addFieldMappingFactory(Time.class, new JdbcTimeMapper.Factory());
+        lookup.addFieldMappingFactory(DateTime.class, new JdbcDateTimeMapper.Factory());
+        lookup.addFieldMappingFactory(TimeStamp.class, new JdbcTimestampMapper.Factory());
+
+        lookup.addFieldMappingFactory(java.sql.Date.class, new JdbcDateMapper.Factory());
+        lookup.addFieldMappingFactory(java.sql.Time.class, new JdbcTimeMapper.Factory());
+        lookup.addFieldMappingFactory(java.util.Date.class, new JdbcDateTimeMapper.Factory());
+        lookup.addFieldMappingFactory(java.sql.Timestamp.class, new JdbcTimestampMapper.Factory());
+
+        lookup.addFieldMappingFactory(boolean.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_BOOLEAN()));
+        lookup.addFieldMappingFactory(short.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_SHORT()));
+        lookup.addFieldMappingFactory(int.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_INT()));
+        lookup.addFieldMappingFactory(long.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_LONG()));
+        lookup.addFieldMappingFactory(float.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_FLOAT()));
+        lookup.addFieldMappingFactory(double.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_DOUBLE()));
+
+        lookup.setReferenceFieldMappingFactory(new JdbcObjectReferenceFieldMapping.Factory());
+
+        lookup.setObjectReferenceMappingfactory(new JdbcObjectReferenceMappingFactory());
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMapping.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMapping.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMapping.java
new file mode 100644
index 0000000..0cc664e
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMapping.java
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.sql.mapping;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.objectstore.sql.DatabaseConnector;
+import org.apache.isis.objectstore.sql.Results;
+
+public interface FieldMapping {
+	
+    public ObjectAssociation getField();
+
+    void appendColumnDefinitions(StringBuffer sql);
+
+    void appendColumnNames(StringBuffer sql);
+
+    void appendInsertValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
+
+    void appendUpdateValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
+
+    void initializeField(ObjectAdapter object, Results rs);
+
+    void appendWhereClause(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
+
+    void debugData(DebugBuilder debug);
+
+    void appendWhereObject(DatabaseConnector connector, ObjectAdapter objectAdapter);
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMappingFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMappingFactory.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMappingFactory.java
new file mode 100644
index 0000000..4a139cf
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/FieldMappingFactory.java
@@ -0,0 +1,27 @@
+/*
+ *  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.isis.objectstore.sql.mapping;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+
+public interface FieldMappingFactory {
+    FieldMapping createFieldMapping(final ObjectSpecification object, final ObjectAssociation field);
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMapping.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMapping.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMapping.java
new file mode 100644
index 0000000..e064cbe
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMapping.java
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.objectstore.sql.mapping;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.objectstore.sql.DatabaseConnector;
+import org.apache.isis.objectstore.sql.Results;
+
+public interface ObjectReferenceMapping {
+
+    void appendColumnDefinitions(StringBuffer sql);
+
+    void appendInsertValues(DatabaseConnector connector, StringBuffer sb, ObjectAdapter value);
+
+    void appendColumnNames(StringBuffer sql);
+
+    void appendUpdateValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object);
+
+    Oid recreateOid(final Results rs, final ObjectSpecification specification);
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMappingFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMappingFactory.java b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMappingFactory.java
new file mode 100644
index 0000000..6a13d63
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/main/java/org/apache/isis/objectstore/sql/mapping/ObjectReferenceMappingFactory.java
@@ -0,0 +1,26 @@
+/*
+ *  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.isis.objectstore.sql.mapping;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public interface ObjectReferenceMappingFactory {
+    ObjectReferenceMapping createReferenceMapping(String columnName, ObjectSpecification specification);
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/site/apt/index.apt b/mothballed/component/objectstore/sql/sql-impl/src/site/apt/index.apt
new file mode 100644
index 0000000..891352a
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/site/apt/index.apt
@@ -0,0 +1,27 @@
+~~  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.
+
+
+
+SQL ObjectStore Implementation
+
+ This module holds the implementation of the {{{../index.html}SQL ObjectStore}}.
+
+Further Info
+  
+ See this module's {{{./apidocs/index.html}Javadoc}} and {{{../docbkx/html/guide/isis-sql-objectstore.html}User Guide}} for more information.
+

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/site/apt/jottings.apt b/mothballed/component/objectstore/sql/sql-impl/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~  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.
+
+
+
+Jottings
+ 
+  This page is to capture any random jottings relating to this module prior 
+  to being moved into formal documentation. 
+ 

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/site/site.xml
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/site/site.xml b/mothballed/component/objectstore/sql/sql-impl/src/site/site.xml
new file mode 100644
index 0000000..fea0aec
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/site/site.xml
@@ -0,0 +1,40 @@
+<?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.
+-->
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="Implementation" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="SQL Objectstore Implementation">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="SQL OS Modules">
+            <item name="Implementation" href="../sql-impl/index.html" />
+            <item name="Tests" href="../sql-tests-common/index.html" />
+            <item name="Integration Tests" href="../sql-tests-served/index.html" /> 
+        </menu>
+
+        <menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java b/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java
new file mode 100644
index 0000000..86b5db4
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/DefaultsTest.java
@@ -0,0 +1,60 @@
+/*
+ *  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.isis.objectstore.sql;
+
+import static org.hamcrest.Matchers.is;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+
+public class DefaultsTest {
+    @Test
+    public void tablePrefixDefaultsTo_Isis() {
+        final String prefix = "isis.persistor.sql";
+        final IsisConfiguration config = new IsisConfigurationDefault();
+        Defaults.initialise(prefix, config);
+        Assert.assertThat(Defaults.getTablePrefix(), is("isis_"));
+    }
+
+    @Test
+    public void tablePrefixCanBeReplaced() {
+        final String prefix = "isis.persistor.sql";
+        final String key = "isis.persistor.sql.default.tableprefix";
+        final IsisConfigurationDefault config = new IsisConfigurationDefault();
+        config.add(key, "");
+        Defaults.initialise(prefix, config);
+        Assert.assertThat(Defaults.getTablePrefix(), is(""));
+    }
+    
+    @Test 
+    public void checkLimitStatement(){
+        final String prefix = "isis.persistor.sql";
+        final IsisConfigurationDefault config = new IsisConfigurationDefault();
+        Defaults.initialise(prefix, config);
+        
+        final long startIndex=0;
+        final long rowCount=0;
+        
+        Assert.assertThat(Defaults.getLimitsClause(startIndex, rowCount), is("LIMIT 0, 0"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java b/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
new file mode 100644
index 0000000..e2a976a
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-impl/src/test/java/org/apache/isis/objectstore/sql/jdbc/helpers/SimplePasswordEncoderDecoderTest.java
@@ -0,0 +1,66 @@
+/**
+ *  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.isis.objectstore.sql.jdbc.helpers;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class SimplePasswordEncoderDecoderTest {
+
+    private static final String testSeed = "randomString12345";
+    private static final Integer encLength = 120;
+
+    @Test
+    public void testEncodingValueFromString() {
+        SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(testSeed, encLength);
+        String input = "password";
+        String encoded = encdec.encodeRawValueIntoEncodedString(input);
+        Assert.assertThat(encoded, is(not(input)));
+        Assert.assertThat(encoded.length(), is(120));
+    }
+
+    @Test
+    public void testDecodingEncodedValue() {
+        SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(testSeed, encLength);
+        String input = "password";
+        String encoded = encdec.encodeRawValueIntoEncodedString(input);
+        Assert.assertThat(encoded, is(not(input)));
+
+        String decoded = encdec.decodeEncodedValueIntoRawString(encoded);
+        Assert.assertThat(decoded, is(input));
+    }
+
+    @Test
+    public void testNoSeedDoesNothing() {
+        SimplePasswordEncoderDecoder encdec = new SimplePasswordEncoderDecoder(null, encLength);
+        String input = "password";
+        String encoded = encdec.encodeRawValueIntoEncodedString(input);
+        Assert.assertThat(encoded, is(input));
+
+        String decoded = encdec.decodeEncodedValueIntoRawString(encoded);
+        Assert.assertThat(decoded, is(input));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-tests-common/pom.xml
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-tests-common/pom.xml b/mothballed/component/objectstore/sql/sql-tests-common/pom.xml
new file mode 100644
index 0000000..829c1e4
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-tests-common/pom.xml
@@ -0,0 +1,166 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.isis.objectstore</groupId>
+        <artifactId>isis-objectstore-sql</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>isis-objectstore-sql-tests-common</artifactId>
+
+    <name>Isis SQL ObjectStore Integration Tests - Common</name>
+
+    <properties>
+	    <siteBaseDir>..</siteBaseDir>
+		<relativeUrl>sql-tests-common/</relativeUrl>
+
+        <xml-objectstore.version>1.0.0-SNAPSHOT</xml-objectstore.version>
+        <hsqldb.version>2.2.9</hsqldb.version>
+    </properties>
+
+    <!-- used in Site generation for relative references. -->
+    <url>http://isis.apache.org/${relativeUrl}</url>
+
+    <description>Common code to test the sql persistor. Uses the HSQLDB for maximum compatibility.</description>
+    <build>
+        <plugins>
+            <!-- TODO: currently set to ignore test failures -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <testFailureIgnore>false</testFailureIgnore>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-project-info-reports-plugin</artifactId>
+				<version>${maven-project-info-reports-plugin}</version>
+                <inherited>false</inherited>
+                <configuration>
+                	<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+                </configuration>
+                <reportSets>
+                    <reportSet>
+                        <inherited>false</inherited>
+                        <reports>
+                            <report>dependency-management</report>
+                            <report>dependencies</report>
+                            <report>dependency-convergence</report>
+                            <report>plugins</report>
+                            <report>summary</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+        </plugins>
+    </reporting>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.hsqldb</groupId>
+                <artifactId>hsqldb</artifactId>
+                <version>${hsqldb.version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-unittestsupport</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-integtestsupport</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-runtime</artifactId>
+        </dependency>
+
+        
+        <!--  Required for TestProxy -->
+		<!-- Isis defaults -->
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-objectstore</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-objectstore</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.isis.core</groupId>
+        	<artifactId>isis-core-bytecode-cglib</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+		<!-- Isis Object store -->
+        <dependency>
+            <groupId>org.apache.isis.objectstore</groupId>
+            <artifactId>isis-objectstore-sql-impl</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-tck-dom</artifactId>
+        </dependency>
+
+
+        <!-- HSQLDB -->
+        <dependency>
+            <groupId>org.hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+        </dependency>
+        <!-- Required to support the XML cross-test -->
+        <dependency>
+            <groupId>org.apache.isis.objectstore</groupId>
+            <artifactId>isis-objectstore-xml</artifactId>
+        </dependency>
+		<!-- others -->
+        <dependency>
+            <groupId>org.jmock</groupId>
+            <artifactId>jmock-legacy</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jmock</groupId>
+            <artifactId>jmock-junit4</artifactId>
+        </dependency>
+        <dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/isis/blob/40561609/mothballed/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java
----------------------------------------------------------------------
diff --git a/mothballed/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java b/mothballed/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java
new file mode 100644
index 0000000..f54f756
--- /dev/null
+++ b/mothballed/component/objectstore/sql/sql-tests-common/src/main/java/org/apache/isis/objectstore/sql/common/Data.java
@@ -0,0 +1,100 @@
+/*
+ *  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.isis.objectstore.sql.common;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.isis.applib.value.Color;
+import org.apache.isis.applib.value.Date;
+import org.apache.isis.applib.value.DateTime;
+import org.apache.isis.applib.value.Image;
+import org.apache.isis.applib.value.Money;
+import org.apache.isis.applib.value.Password;
+import org.apache.isis.applib.value.Percentage;
+import org.apache.isis.applib.value.Time;
+import org.apache.isis.applib.value.TimeStamp;
+
+public class Data {
+
+    // private static final TimeZone GMTm2_TIME_ZONE;
+
+    // Helper values
+    static final java.sql.Date sqlDate;
+    static final java.sql.Date sqlDate20100305;
+
+    static {
+        /*
+         * 
+         * // For testing -ve offset timezone local regions. GMTm2_TIME_ZONE = TimeZone.getTimeZone("GMT-0200");
+         * //GMTm2_TIME_ZONE = TimeZone.getTimeZone("UTC"); TimeZone.setDefault(GMTm2_TIME_ZONE);
+         */
+
+        /*
+         * TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC"); if (timeZone == null) { timeZone =
+         * TimeZone.getTimeZone("UTC"); } UTC_TIME_ZONE = timeZone;
+         */
+
+        /*
+         * There is still an issue assigning a java.sql.Date variable from a calendar. final Calendar cal =
+         * Calendar.getInstance(); cal.setTimeZone(UTC_TIME_ZONE); cal.clear(); cal.set(Calendar.YEAR, 2011);
+         * cal.set(Calendar.MONTH, 4-1); cal.set(Calendar.DAY_OF_MONTH, 8);
+         */
+        // 2011-4-8 = 1,270,684,800,000
+        final Date date20100308 = new Date(2010, 4, 8);
+        sqlDate = new java.sql.Date(date20100308.getMillisSinceEpoch());
+
+        sqlDate20100305 = new java.sql.Date(new Date(2010, 3, 5).getMillisSinceEpoch());
+    }
+
+    static final Date applibDate = new Date(2010, 3, 5); // 2010-03-05 =
+                                                         // 1,267,747,200,000
+    static final DateTime dateTime = new DateTime(2010, 3, 5, 1, 23); // 1,267,752,180,000
+    static final TimeStamp timeStamp = new TimeStamp(dateTime.millisSinceEpoch());
+    static final Time time = new Time(14, 56); // 53,760,000
+
+    static final Color color = Color.WHITE;
+    static final Image image = new Image(new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } });
+    static final Password password = new Password("password");
+    static final Percentage percentage = new Percentage(42);
+    static final Money money = new Money(99.99, "ZAR");
+
+    // Standard values
+    static final int intMaxValue = Integer.MAX_VALUE;
+    static final short shortMaxValue = Short.MAX_VALUE;
+    static final long longMaxValue = Long.MAX_VALUE;
+    static final double doubleMaxValue = 1e308;// Double.MAX_VALUE;
+    static final float floatMaxValue = (float) 1e37;// Float.MAX_VALUE;
+
+    static final int intMinValue = Integer.MIN_VALUE;
+    static final short shortMinValue = Short.MIN_VALUE;
+    static final long longMinValue = Long.MIN_VALUE;
+    static final double doubleMinValue = 1e-307;// Double.MIN_VALUE;
+    static final float floatMinValue = (float) 1e-37;// Float.MIN_VALUE;
+
+    // Collection mapper tests
+    static final List<String> stringList1 = Arrays.asList("Baking", "Bakery", "Canned", "Dairy");
+    static final List<String> stringList2 = Arrays.asList("Fridge", "Deli", "Fresh Produce", "Frozen", "Household",
+        "Other..");
+
+    public static List<String> getTableNames() {
+        return Arrays.asList("sqldataclass", "simpleclass", "simpleclasstwo", "primitivevaluedentity");
+    }
+
+}