You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/10/09 23:19:28 UTC

svn commit: r583302 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/dba/sqlite/ main/resources/org/apache/cayenne/dba/sqlite/ test/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/access/jdbc/...

Author: aadamchik
Date: Tue Oct  9 14:19:25 2007
New Revision: 583302

URL: http://svn.apache.org/viewvc?rev=583302&view=rev
Log:
CAY-875 DbAdapter for SQLite
(initial adapter. Unit tests stats stand at Failures: 16, Errors: 29)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteActionBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteBigDecimalType.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteDateType.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteFloatType.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSQLTemplateAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/resources/org/apache/cayenne/dba/sqlite/
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/resources/org/apache/cayenne/dba/sqlite/types.xml
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/SQLiteStackAdapter.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/spring-test-resources.xml

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteActionBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteActionBuilder.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteActionBuilder.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteActionBuilder.java Tue Oct  9 14:19:25 2007
@@ -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.cayenne.dba.sqlite;
+
+import org.apache.cayenne.dba.JdbcActionBuilder;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.query.SQLAction;
+import org.apache.cayenne.query.SQLTemplate;
+
+/**
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class SQLiteActionBuilder extends JdbcActionBuilder {
+
+    SQLiteActionBuilder(JdbcAdapter adapter, EntityResolver resolver) {
+        super(adapter, resolver);
+    }
+
+    public SQLAction sqlAction(SQLTemplate query) {
+        return new SQLiteSQLTemplateAction(query, adapter);
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java Tue Oct  9 14:19:25 2007
@@ -0,0 +1,69 @@
+/*****************************************************************
+ *   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.cayenne.dba.sqlite;
+
+import java.util.Collection;
+
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.types.ExtendedTypeMap;
+import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.query.Query;
+import org.apache.cayenne.query.SQLAction;
+
+/**
+ * A SQLite database adapter that works with Zentus JDBC driver. See
+ * http://www.zentus.com/sqlitejdbc/ for the driver information.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+// check http://cwiki.apache.org/CAY/sqliteadapter.html for current limitations.
+public class SQLiteAdapter extends JdbcAdapter {
+
+    public SQLiteAdapter() {
+        setSupportsFkConstraints(false);
+        this.setSupportsUniqueConstraints(false);
+        this.setSupportsGeneratedKeys(true);
+    }
+
+    protected void configureExtendedTypes(ExtendedTypeMap map) {
+        super.configureExtendedTypes(map);
+        map.registerType(new SQLiteDateType());
+        map.registerType(new SQLiteBigDecimalType());
+        map.registerType(new SQLiteFloatType());
+    }
+
+    public String createFkConstraint(DbRelationship rel) {
+        return null;
+    }
+
+    public String createUniqueConstraint(DbEntity source, Collection columns) {
+        // TODO: andrus 10/9/2007 - only ALTER TABLE ADD CONSTRAINT is not supported,
+        // presumably there's some other syntax (a part of CREATE TABLE?) that would
+        // create a unique constraint.
+        return null;
+    }
+
+    public SQLAction getAction(Query query, DataNode node) {
+        return query.createSQLAction(new SQLiteActionBuilder(this, node
+                .getEntityResolver()));
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteBigDecimalType.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteBigDecimalType.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteBigDecimalType.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteBigDecimalType.java Tue Oct  9 14:19:25 2007
@@ -0,0 +1,53 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dba.sqlite;
+
+import java.math.BigDecimal;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+
+import org.apache.cayenne.access.types.AbstractType;
+
+/**
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class SQLiteBigDecimalType extends AbstractType {
+
+    public String getClassName() {
+        return BigDecimal.class.getName();
+    }
+
+    public Object materializeObject(CallableStatement rs, int index, int type)
+            throws Exception {
+        // BigDecimals are not supported by the zentus driver... in addition the driver
+        // throws an NPE on 'getDouble' if the value is null, so must read it as an
+        // object.
+        Number n = (Number) rs.getObject(index);
+        return (n == null) ? null : new BigDecimal(n.doubleValue());
+    }
+
+    public Object materializeObject(ResultSet rs, int index, int type) throws Exception {
+        // BigDecimals are not supported by the zentus driver... in addition the driver
+        // throws an NPE on 'getDouble' if the value is null, so must read it as an
+        // object.
+        Number n = (Number) rs.getObject(index);
+        return (n == null) ? null : new BigDecimal(n.doubleValue());
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteDateType.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteDateType.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteDateType.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteDateType.java Tue Oct  9 14:19:25 2007
@@ -0,0 +1,87 @@
+/*****************************************************************
+ *   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.cayenne.dba.sqlite;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.Types;
+import java.util.Date;
+
+import org.apache.cayenne.access.types.UtilDateType;
+
+/**
+ * Implements special date handling for SQLite. See
+ * http://www.zentus.com/sqlitejdbc/usage.html for details.
+ * 
+ * @author Andrus Adamchik
+ * @since 3.0
+ */
+class SQLiteDateType extends UtilDateType {
+
+    public Object materializeObject(ResultSet rs, int index, int type) throws Exception {
+
+        Date val = null;
+
+        switch (type) {
+            case Types.TIMESTAMP:
+                val = rs.getTimestamp(index);
+                break;
+            case Types.DATE:
+                val = rs.getDate(index);
+                break;
+            case Types.TIME:
+                val = rs.getTime(index);
+                break;
+            default:
+                // here instead of failing like the super does, simply attempt to convert
+                // to timestamp (note that 'getObject' may return a String... SQLite is
+                // not very robust in type conversions.
+                val = rs.getTimestamp(index);
+                break;
+        }
+
+        return (rs.wasNull()) ? null : new Date(val.getTime());
+    }
+
+    public Object materializeObject(CallableStatement cs, int index, int type)
+            throws Exception {
+        Object val = null;
+
+        switch (type) {
+            case Types.TIMESTAMP:
+                val = cs.getTimestamp(index);
+                break;
+            case Types.DATE:
+                val = cs.getDate(index);
+                break;
+            case Types.TIME:
+                val = cs.getTime(index);
+                break;
+            default:
+                // here instead of failing like the super does, simply attempt to convert
+                // to timestamp (note that 'getObject' may return a String... SQLite is
+                // not very robust in type conversions.
+                val = cs.getTimestamp(index);
+                break;
+        }
+
+        return (cs.wasNull()) ? null : new java.util.Date(((java.util.Date) val)
+                .getTime());
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteFloatType.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteFloatType.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteFloatType.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteFloatType.java Tue Oct  9 14:19:25 2007
@@ -0,0 +1,50 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dba.sqlite;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+
+import org.apache.cayenne.access.types.AbstractType;
+
+/**
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class SQLiteFloatType extends AbstractType {
+
+    public String getClassName() {
+        return Float.class.getName();
+    }
+
+    public Object materializeObject(CallableStatement rs, int index, int type)
+            throws Exception {
+        // the driver throws an NPE on 'getFloat' if the value is null, so must read it as
+        // an object.
+        Number n = (Number) rs.getObject(index);
+        return (n == null) ? null : new Float(n.floatValue());
+    }
+
+    public Object materializeObject(ResultSet rs, int index, int type) throws Exception {
+        // the driver throws an NPE on 'getFloat' if the value is null, so must read it as
+        // an object.
+        Number n = (Number) rs.getObject(index);
+        return (n == null) ? null : new Float(n.floatValue());
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSQLTemplateAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSQLTemplateAction.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSQLTemplateAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteSQLTemplateAction.java Tue Oct  9 14:19:25 2007
@@ -0,0 +1,99 @@
+/*****************************************************************
+ *   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.cayenne.dba.sqlite;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+
+import org.apache.cayenne.access.OperationObserver;
+import org.apache.cayenne.access.QueryLogger;
+import org.apache.cayenne.access.jdbc.SQLStatement;
+import org.apache.cayenne.access.jdbc.SQLTemplateAction;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.query.SQLTemplate;
+
+/**
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class SQLiteSQLTemplateAction extends SQLTemplateAction {
+
+    public SQLiteSQLTemplateAction(SQLTemplate query, DbAdapter adapter) {
+        super(query, adapter);
+    }
+
+    /**
+     * Overrides super implementation to guess whether the query is selecting or not and
+     * execute it appropriately. Super implementation relied on generic JDBC mechanism,
+     * common for selecting and updating statements that does not work in SQLite drivers.
+     */
+    protected void execute(
+            Connection connection,
+            OperationObserver callback,
+            SQLStatement compiled,
+            Collection updateCounts) throws SQLException, Exception {
+
+        String sql = compiled.getSql().trim();
+        boolean select = sql.length() > "SELECT".length()
+                && sql.substring(0, "SELECT".length()).equalsIgnoreCase("SELECT");
+
+        long t1 = System.currentTimeMillis();
+        boolean iteratedResult = callback.isIteratedResult();
+        PreparedStatement statement = connection.prepareStatement(compiled.getSql());
+        try {
+            bind(statement, compiled.getBindings());
+
+            // start - code different from super
+            if (select) {
+
+                ResultSet resultSet = statement.executeQuery();
+                try {
+                    processSelectResult(
+                            compiled,
+                            connection,
+                            statement,
+                            resultSet,
+                            callback,
+                            t1);
+                }
+                finally {
+                    if (!iteratedResult) {
+                        resultSet.close();
+                    }
+                }
+            }
+            else {
+                int updateCount = statement.executeUpdate();
+                updateCounts.add(new Integer(updateCount));
+                QueryLogger.logUpdateCount(updateCount);
+            }
+
+            // end - code different from super
+        }
+        finally {
+            if (!iteratedResult) {
+                statement.close();
+            }
+        }
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/resources/org/apache/cayenne/dba/sqlite/types.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/resources/org/apache/cayenne/dba/sqlite/types.xml?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/resources/org/apache/cayenne/dba/sqlite/types.xml (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/resources/org/apache/cayenne/dba/sqlite/types.xml Tue Oct  9 14:19:25 2007
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+
+<!-- 
+SQLite types mapping
+
+Driver url:
+http://www.zentus.com/sqlitejdbc/
+-->
+
+<types>
+   <jdbc-type name="ARRAY">
+       <db-type name="ARRAY"/>
+   </jdbc-type>
+   <jdbc-type name="BIGINT">
+       <db-type name="BIGINT"/>
+   </jdbc-type>
+   <jdbc-type name="BINARY">
+       <db-type name="CHAR FOR BIT DATA"/>
+   </jdbc-type>
+   <jdbc-type name="BIT">
+       <db-type name="SMALLINT"/>
+   </jdbc-type>
+   <jdbc-type name="BLOB">
+       <db-type name="BLOB"/>
+   </jdbc-type>
+   <jdbc-type name="BOOLEAN">
+       <db-type name="SMALLINT"/>
+   </jdbc-type>
+   <jdbc-type name="CHAR">
+       <db-type name="CHAR"/>
+   </jdbc-type>
+   <jdbc-type name="CLOB">
+       <db-type name="CLOB"/>
+   </jdbc-type>
+   <jdbc-type name="DATALINK">
+       <db-type name="DATALINK"/>
+   </jdbc-type>
+   <jdbc-type name="DATE">
+       <db-type name="DATE"/>
+   </jdbc-type>
+   <jdbc-type name="DECIMAL">
+       <db-type name="DECIMAL"/>
+   </jdbc-type>
+   <jdbc-type name="DOUBLE">
+       <db-type name="DOUBLE PRECISION"/>
+   </jdbc-type>
+   <jdbc-type name="FLOAT">
+       <db-type name="DOUBLE PRECISION"/>
+   </jdbc-type>
+   <jdbc-type name="INTEGER">
+       <db-type name="INTEGER"/>
+   </jdbc-type>
+   <jdbc-type name="JAVA_OBJECT">
+       <db-type name="JAVA_OBJECT"/>
+   </jdbc-type>
+   <jdbc-type name="LONGVARBINARY">
+       <db-type name="LONG VARCHAR FOR BIT DATA"/>
+   </jdbc-type>
+   <jdbc-type name="LONGVARCHAR">
+       <db-type name="LONG VARCHAR"/>
+   </jdbc-type>
+   <jdbc-type name="NUMERIC">
+       <db-type name="DECIMAL"/>
+   </jdbc-type>
+   <jdbc-type name="OTHER">
+       <db-type name="OTHER"/>
+   </jdbc-type>
+   <jdbc-type name="REAL">
+       <db-type name="REAL"/>
+   </jdbc-type>
+   <jdbc-type name="REF">
+       <db-type name="REF"/>
+   </jdbc-type>
+   <jdbc-type name="SMALLINT">
+       <db-type name="SMALLINT"/>
+   </jdbc-type>
+   <jdbc-type name="STRUCT">
+       <db-type name="STRUCT"/>
+   </jdbc-type>
+   <jdbc-type name="TIME">
+       <db-type name="TIME"/>
+   </jdbc-type>
+   <jdbc-type name="TIMESTAMP">
+       <db-type name="TIMESTAMP"/>
+   </jdbc-type>
+   <jdbc-type name="TINYINT">
+       <db-type name="SMALLINT"/>
+   </jdbc-type>
+   <jdbc-type name="VARBINARY">
+       <db-type name="VARCHAR FOR BIT DATA"/>
+   </jdbc-type>
+   <jdbc-type name="VARCHAR">
+       <db-type name="VARCHAR"/>
+   </jdbc-type>
+</types>

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java?rev=583302&r1=583301&r2=583302&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextTest.java Tue Oct  9 14:19:25 2007
@@ -186,7 +186,9 @@
                         "estimatedPrice",
                         new BigDecimal(1000d)));
 
-        ArtistAssets a1 = (ArtistAssets) context.performQuery(q).get(0);
+        List results = context.performQuery(q);
+        assertEquals(1, results.size());
+        ArtistAssets a1 = (ArtistAssets) results.get(0);
         assertEquals(1, a1.getPaintingsCount().intValue());
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java?rev=583302&r1=583301&r2=583302&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionTest.java Tue Oct  9 14:19:25 2007
@@ -32,6 +32,7 @@
 import org.apache.cayenne.access.QueryResult;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
@@ -65,8 +66,10 @@
         bindings.put("id", new Integer(33005));
         template.setParameters(bindings);
 
+        // must ensure the right SQLTemplateAction is created
         DbAdapter adapter = getAccessStackAdapter().getAdapter();
-        SQLTemplateAction plan = new SQLTemplateAction(template, adapter);
+        SQLAction plan = adapter.getAction(template, getNode());
+        assertTrue(plan instanceof SQLTemplateAction);
 
         MockOperationObserver observer = new MockOperationObserver();
         Connection c = getConnection();
@@ -103,7 +106,7 @@
         template.setParameters(bindings);
 
         DbAdapter adapter = getAccessStackAdapter().getAdapter();
-        SQLTemplateAction plan = new SQLTemplateAction(template, adapter);
+        SQLAction plan = adapter.getAction(template, getNode());
 
         MockOperationObserver observer = new MockOperationObserver();
         Connection c = getConnection();
@@ -139,7 +142,7 @@
         template.setParameters(bindings);
 
         DbAdapter adapter = getAccessStackAdapter().getAdapter();
-        SQLTemplateAction plan = new SQLTemplateAction(template, adapter);
+        SQLAction plan = adapter.getAction(template, getNode());
 
         MockOperationObserver observer = new MockOperationObserver();
         Connection c = getConnection();
@@ -175,13 +178,13 @@
         template.setParameters(bindings);
 
         DbAdapter adapter = getAccessStackAdapter().getAdapter();
-        SQLTemplateAction action = new SQLTemplateAction(template, adapter);
+        SQLAction plan = adapter.getAction(template, getNode());
 
         MockOperationObserver observer = new MockOperationObserver();
         Connection c = getConnection();
 
         try {
-            action.performAction(c, observer);
+            plan.performAction(c, observer);
         }
         finally {
             c.close();
@@ -208,10 +211,8 @@
         bindings.put("dob", new Date(System.currentTimeMillis()));
         template.setParameters(bindings);
 
-        SQLTemplateAction action = new SQLTemplateAction(
-                template,
-                getAccessStackAdapter().getAdapter());
-        assertSame(getAccessStackAdapter().getAdapter(), action.getAdapter());
+        DbAdapter adapter = getAccessStackAdapter().getAdapter();
+        SQLAction action = adapter.getAction(template, getNode());
 
         Connection c = getConnection();
         try {
@@ -245,14 +246,13 @@
 
         SQLTemplate template = new SQLTemplate(Object.class, "delete from ARTIST");
 
-        SQLTemplateAction plan = new SQLTemplateAction(template, getAccessStackAdapter()
-                .getAdapter());
-        assertSame(getAccessStackAdapter().getAdapter(), plan.getAdapter());
+        DbAdapter adapter = getAccessStackAdapter().getAdapter();
+        SQLAction action = adapter.getAction(template, getNode());
 
         Connection c = getConnection();
         try {
             MockOperationObserver observer = new MockOperationObserver();
-            plan.performAction(c, observer);
+            action.performAction(c, observer);
 
             int[] batches = observer.countsForQuery(template);
             assertNotNull(batches);
@@ -282,9 +282,11 @@
                 bindings1, bindings2
         });
 
-        SQLTemplateAction action = new SQLTemplateAction(
-                template,
-                getAccessStackAdapter().getAdapter());
+        DbAdapter adapter = getAccessStackAdapter().getAdapter();
+        SQLAction genericAction = adapter.getAction(template, getNode());
+        assertTrue(genericAction instanceof SQLTemplateAction);
+        SQLTemplateAction action = (SQLTemplateAction) genericAction;
+
         assertSame(getAccessStackAdapter().getAdapter(), action.getAdapter());
         assertSame(template, action.getQuery());
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/SQLiteStackAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/SQLiteStackAdapter.java?rev=583302&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/SQLiteStackAdapter.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/SQLiteStackAdapter.java Tue Oct  9 14:19:25 2007
@@ -0,0 +1,28 @@
+/*****************************************************************
+ *   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.cayenne.unit;
+
+import org.apache.cayenne.dba.DbAdapter;
+
+public class SQLiteStackAdapter extends AccessStackAdapter {
+
+    public SQLiteStackAdapter(DbAdapter adapter) {
+        super(adapter);
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/spring-test-resources.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/spring-test-resources.xml?rev=583302&r1=583301&r2=583302&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/spring-test-resources.xml (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/spring-test-resources.xml Tue Oct  9 14:19:25 2007
@@ -17,6 +17,7 @@
 	<bean id="DerbyAdapter" class="org.apache.cayenne.dba.derby.DerbyAdapter"/>
 	<bean id="FrontBaseAdapter" class="org.apache.cayenne.dba.frontbase.FrontBaseAdapter"/>
 	<bean id="IngresAdapter" class="org.apache.cayenne.dba.ingres.IngresAdapter"/>
+	<bean id="SQLiteAdapter" class="org.apache.cayenne.dba.sqlite.SQLiteAdapter"/>
 
 	<!-- ======================================= -->
 	<!-- Access Stack Adapters -->
@@ -57,6 +58,9 @@
 	<bean id="IngresStackAdapter" class="org.apache.cayenne.unit.IngresStackAdapter">
 		<constructor-arg><ref bean="IngresAdapter"/></constructor-arg>
 	</bean>
+	<bean id="SQLiteStackAdapter" class="org.apache.cayenne.unit.SQLiteStackAdapter">
+		<constructor-arg><ref bean="SQLiteAdapter"/></constructor-arg>
+	</bean>
 	
 	<!-- ======================================= -->
 	<!-- DataMaps -->
@@ -187,6 +191,7 @@
 				<entry key="org.apache.cayenne.dba.derby.DerbyAdapter"><ref bean="DerbyStackAdapter"/></entry>
 				<entry key="org.apache.cayenne.dba.frontbase.FrontBaseAdapter"><ref bean="FrontBaseStackAdapter"/></entry>
 				<entry key="org.apache.cayenne.dba.ingres.IngresAdapter"><ref bean="IngresStackAdapter"/></entry>
+				<entry key="org.apache.cayenne.dba.sqlite.SQLiteAdapter"><ref bean="SQLiteStackAdapter"/></entry>
 			</map>
 		</constructor-arg>
 	</bean>