db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r409364 - in /db/torque: generator/trunk/src/java/org/apache/torque/engine/platform/ runtime/trunk/src/java/org/apache/torque/adapter/ site/trunk/xdocs/
Date Thu, 25 May 2006 11:40:30 GMT
Author: tfischer
Date: Thu May 25 04:40:29 2006
New Revision: 409364

URL: http://svn.apache.org/viewvc?rev=409364&view=rev
Log:
-Added adapter class for firebird
-corrected datatype mapping and date generation in adapters for interbase and firebird
Fixes TORQUE-4. Thanks to Joerg Friedrich for the patch.

Added:
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java
Modified:
    db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java
    db/torque/site/trunk/xdocs/changes.xml

Modified: db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java?rev=409364&r1=409363&r2=409364&view=diff
==============================================================================
--- db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java
(original)
+++ db/torque/generator/trunk/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java
Thu May 25 04:40:29 2006
@@ -42,8 +42,8 @@
     private void initialize()
     {
         setSchemaDomainMapping(new Domain(SchemaType.BIT, "NUMERIC", "1", "0"));
-        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
-        setSchemaDomainMapping(new Domain(SchemaType.BOOLEANCHAR, "VARCHAR", "1"));
+        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "DOUBLE PRECISION"));
+        setSchemaDomainMapping(new Domain(SchemaType.BOOLEANCHAR, "CHAR", "1"));
         setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR"));
         setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BLOB"));
     }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java?rev=409364&r1=409363&r2=409364&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java Thu May 25 04:40:29
2006
@@ -47,6 +47,7 @@
         adapters.put("COM.ibm.db2.jdbc.app.DB2Driver", DBDB2App.class);
         adapters.put("COM.ibm.db2.jdbc.net.DB2Driver", DBDB2Net.class);
         adapters.put("COM.cloudscape.core.JDBCDriver", DBCloudscape.class);
+        adapters.put("org.firebirdsql.jdbc.FBDriver",DBFirebird.class);
         adapters.put("org.hsql.jdbcDriver", DBHypersonicSQL.class);
         adapters.put("org.hsqldb.jdbcDriver", DBHypersonicSQL.class);
         adapters.put("interbase.interclient.Driver", DBInterbase.class);
@@ -74,6 +75,7 @@
         adapters.put("db2app", DBDB2App.class);
         adapters.put("db2net", DBDB2Net.class);
         adapters.put("cloudscape", DBCloudscape.class);
+        adapters.put("firebird", DBFirebird.class);
         adapters.put("hypersonic", DBHypersonicSQL.class);
         adapters.put("interbase", DBInterbase.class);
         adapters.put("instantdb", DBInstantDB.class);

Added: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java?rev=409364&view=auto
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java (added)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java Thu May 25
04:40:29 2006
@@ -0,0 +1,149 @@
+package org.apache.torque.adapter;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+
+/**
+ * This code should be used for a Firebird database pool.
+ *
+ * @author Joerg Friedrich
+ * @version $Id: DBInterbase.java 239630 2005-08-24 12:25:32Z henning $
+ */
+public class DBFirebird extends DB
+{
+
+    private static final String DATE_FORMAT = "yyyy-MM-dd HH:MM:ss";
+
+    /**
+     * This method is used to ignore case.
+     *
+     * @param in The string to transform to upper case.
+     * @return The upper case string.
+     */
+    public String toUpperCase(String in)
+    {
+        return new StringBuffer("UPPER(").append(in).append(")").toString();
+    }
+
+    /**
+     * This method is used to ignore case.
+     *
+     * @param in The string whose case to ignore.
+     * @return The string in a case that can be ignored.
+     */
+    public String ignoreCase(String in)
+    {
+        return new StringBuffer("UPPER(").append(in).append(")").toString();
+    }
+
+    /**
+     * This method is used to ignore case in an ORDER BY clause.
+     * Usually it is the same as ignoreCase, but some databases
+     * (Interbase for example) does not use the same SQL in ORDER BY
+     * and other clauses.
+     *
+     * @param in The string whose case to ignore.
+     * @return The string in a case that can be ignored.
+     */
+    public String ignoreCaseInOrderBy(String in)
+    {
+        return in;
+    }
+
+    /**
+     * Gets the string delimiter (usually '\'').
+     *
+     * @return The delimiter.
+     */
+    public char getStringDelimiter()
+    {
+        return '\'';
+    }
+
+    /**
+     * @see org.apache.torque.adapter.DB#getIDMethodType()
+     */
+    public String getIDMethodType()
+    {
+        return NO_ID_METHOD;
+    }
+
+    /**
+     * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
+     */
+    public String getIDMethodSQL(Object obj)
+    {
+        return null;
+    }
+
+    /**
+     * Locks the specified table.
+     *
+     * @param con The JDBC connection to use.
+     * @param table The name of the table to lock.
+     * @exception SQLException No Statement could be created or executed.
+     */
+    public void lockTable(Connection con, String table) throws SQLException
+    {
+        Statement statement = con.createStatement();
+
+        StringBuffer stmt = new StringBuffer();
+        stmt.append("SET TRANSACTION ")
+                .append("ISOLATION LEVEL READ COMMITTED ")
+                .append("NO RECORD_VERSION WAIT ")
+                .append("RESERVING ")
+                .append(table)
+                .append(" FOR PROTECTED WRITE");
+
+        statement.executeQuery(stmt.toString());
+    }
+
+    /**
+     * Unlocks the specified table.
+     *
+     * @param con The JDBC connection to use.
+     * @param table The name of the table to unlock.
+     * @exception SQLException No Statement could be created or executed.
+     */
+    public void unlockTable(Connection con, String table) throws SQLException
+    {
+        // Tables in Interbase are unlocked when a commit is issued.
+        // The user may have issued a commit but do it here to be
+        // sure.
+        con.commit();
+    }
+
+
+    /**
+     * This method overrides the JDBC escapes used to format dates
+     * using a <code>DateFormat</code>.  As of version 2.0.11, the MM
+     * JDBC driver does not implement JDBC 3.0 escapes.
+     *
+     * @param date the date to format
+     * @return The properly formatted date String.
+     */
+    public String getDateString(Date date)
+    {
+        char delim = getStringDelimiter();
+        return (delim + new SimpleDateFormat(DATE_FORMAT).format(date) + delim);
+    }
+}

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java?rev=409364&r1=409363&r2=409364&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java Thu May 25
04:40:29 2006
@@ -19,6 +19,8 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Date;
+import java.text.SimpleDateFormat;
 
 /**
  * This code should be used for an Interbase database pool.
@@ -28,6 +30,9 @@
  */
 public class DBInterbase extends DB
 {
+
+    private static final String DATE_FORMAT = "yyyy-MM-dd HH:MM:ss";
+
     /**
      * This method is used to ignore case.
      *
@@ -125,5 +130,20 @@
         // The user may have issued a commit but do it here to be
         // sure.
         con.commit();
+    }
+
+
+    /**
+     * This method overrides the JDBC escapes used to format dates
+     * using a <code>DateFormat</code>.  As of version 2.0.11, the MM
+     * JDBC driver does not implement JDBC 3.0 escapes.
+     *
+     * @param date the date to format
+     * @return The properly formatted date String.
+     */
+    public String getDateString(Date date)
+    {
+        char delim = getStringDelimiter();
+        return (delim + new SimpleDateFormat(DATE_FORMAT).format(date) + delim);
     }
 }

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?rev=409364&r1=409363&r2=409364&view=diff
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Thu May 25 04:40:29 2006
@@ -29,6 +29,33 @@
 
   <release version="3.2.1-dev" date="in SVN">
   
+    <action type="fix" dev="tfischer" issue="TORQUE-4" due-to="Joerg Friedrich">
+      <ul>
+        <li>
+          Added new firebird database adapter.
+        </li>
+        <li>
+          Date Strings returned by the interbase and firebird adapters
+          are now escaped.
+        </li>
+      </ul>
+    </action>
+    <action type="fix" dev="tfischer" issue="TORQUE-4" due-to="Joerg Friedrich">
+      Corrected Mappings for firebird:
+      <ul>
+        <li>
+          Torque type char is now mapped to firebird type char (was varchar)
+        </li>
+        <li>
+          Torque type double is now mapped to firebird type double precision 
+          (was double)
+        </li>
+        <li>
+          Torque type booleanchar is now mapped to firebird type char(1) 
+          (was varchar(1))
+        </li>
+      </ul>
+    </action>
     <action type="fix" dev="tfischer" issue="TRQS356">
       Corrected Mapping for Type LONGVARCHAR for Derby.
     </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message