From 689eec175b9b0743785fec5db31cada6bd1fea59 Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Wed, 21 May 2008 03:23:18 +0000 Subject: [PATCH] OPENJPA-606 InformixDictionary default property setting incorrectly set. Also fixed SQL problems as described in the issue. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@658544 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/kernel/exps/Distinct.java | 15 ++++++++++ .../openjpa/jdbc/sql/InformixDictionary.java | 28 +++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java index b605c08ce..2e687c0a4 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java @@ -18,6 +18,7 @@ */ package org.apache.openjpa.jdbc.kernel.exps; +import org.apache.openjpa.jdbc.sql.SQLBuffer; import org.apache.openjpa.jdbc.sql.Select; /** @@ -40,4 +41,18 @@ class Distinct protected String getOperator() { return "DISTINCT"; } + + + public void appendTo(Select sel, ExpContext ctx, ExpState state, + SQLBuffer sql, int index) { + if (sel.getConfiguration().getDBDictionaryInstance().platform.indexOf( + "Informix") > -1) { + sql.append(getOperator()); + sql.append(" "); + getValue().appendTo(sel, ctx, state, sql, 0); + sql.addCastForParam(getOperator(), getValue()); + } + else + super.appendTo(sel, ctx, state, sql, index); + } } diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java index e03b63d0e..7eca5e89b 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java @@ -28,12 +28,14 @@ import java.sql.Types; import java.util.Arrays; import java.util.Collection; +import org.apache.openjpa.jdbc.kernel.exps.FilterValue; import org.apache.openjpa.jdbc.schema.Column; import org.apache.openjpa.jdbc.schema.ForeignKey; import org.apache.openjpa.jdbc.schema.Index; import org.apache.openjpa.jdbc.schema.PrimaryKey; import org.apache.openjpa.jdbc.schema.Table; import org.apache.openjpa.lib.util.ReferenceHashSet; +import org.apache.openjpa.util.UnsupportedException; /** * Dictionary for Informix database. Notable features: @@ -91,11 +93,6 @@ public class InformixDictionary supportsDeferredConstraints = false; constraintNameMode = CONS_NAME_AFTER; - maxTableNameLength = 18; - maxColumnNameLength = 18; - maxIndexNameLength = 18; - maxConstraintNameLength = 18; - // informix supports "CLOB" type, but any attempt to insert // into them raises: "java.sql.SQLException: Can't convert fromnull" useGetStringForClobs = true; @@ -109,7 +106,7 @@ public class InformixDictionary doubleTypeName = "NUMERIC(32,20)"; dateTypeName = "DATE"; timeTypeName = "DATETIME HOUR TO SECOND"; - timestampTypeName = "DATETIME YEAR TO SECOND"; + timestampTypeName = "DATETIME YEAR TO FRACTION(3)"; doubleTypeName = "NUMERIC(32,20)"; floatTypeName = "REAL"; bigintTypeName = "NUMERIC(32,0)"; @@ -133,7 +130,17 @@ public class InformixDictionary // Informix doesn't support aliases in deletes if the table has an index allowsAliasInBulkClause = false; - supportsSubselect = false; + supportsTimestampNanos = false; + + // Informix doesn't understand "X CROSS JOIN Y", but it does understand + // the equivalent "X JOIN Y ON 1 = 1" + crossJoinClause = "JOIN"; + requiresConditionForCrossJoin = true; + + concatenateFunction = "CONCAT({0},{1})"; + nextSequenceQuery = "SELECT {0}.NEXTVAL FROM SYSTABLES WHERE TABID=1"; + supportsCorrelatedSubselect = false; + swapSchemaAndCatalog = false; } public void connectedConfiguration(Connection conn) @@ -190,7 +197,7 @@ public class InformixDictionary throws SQLException { // informix actually requires that a boolean be set: it cannot // handle a numeric argument - stmnt.setBoolean(idx, val); + stmnt.setString(idx, val ? "t" : "f"); } public String[] getCreateTableSQL(Table table) { @@ -256,4 +263,9 @@ public class InformixDictionary } return conn; } + + public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find, + FilterValue start) { + throw new UnsupportedException(); + } }