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
This commit is contained in:
Catalina Wei 2008-05-21 03:23:18 +00:00
parent 99a69bef33
commit 689eec175b
2 changed files with 35 additions and 8 deletions

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.openjpa.jdbc.kernel.exps; package org.apache.openjpa.jdbc.kernel.exps;
import org.apache.openjpa.jdbc.sql.SQLBuffer;
import org.apache.openjpa.jdbc.sql.Select; import org.apache.openjpa.jdbc.sql.Select;
/** /**
@ -40,4 +41,18 @@ class Distinct
protected String getOperator() { protected String getOperator() {
return "DISTINCT"; 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);
}
} }

View File

@ -28,12 +28,14 @@ import java.sql.Types;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; 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.Column;
import org.apache.openjpa.jdbc.schema.ForeignKey; import org.apache.openjpa.jdbc.schema.ForeignKey;
import org.apache.openjpa.jdbc.schema.Index; import org.apache.openjpa.jdbc.schema.Index;
import org.apache.openjpa.jdbc.schema.PrimaryKey; import org.apache.openjpa.jdbc.schema.PrimaryKey;
import org.apache.openjpa.jdbc.schema.Table; import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.lib.util.ReferenceHashSet; import org.apache.openjpa.lib.util.ReferenceHashSet;
import org.apache.openjpa.util.UnsupportedException;
/** /**
* Dictionary for Informix database. Notable features: * Dictionary for Informix database. Notable features:
@ -91,11 +93,6 @@ public class InformixDictionary
supportsDeferredConstraints = false; supportsDeferredConstraints = false;
constraintNameMode = CONS_NAME_AFTER; constraintNameMode = CONS_NAME_AFTER;
maxTableNameLength = 18;
maxColumnNameLength = 18;
maxIndexNameLength = 18;
maxConstraintNameLength = 18;
// informix supports "CLOB" type, but any attempt to insert // informix supports "CLOB" type, but any attempt to insert
// into them raises: "java.sql.SQLException: Can't convert fromnull" // into them raises: "java.sql.SQLException: Can't convert fromnull"
useGetStringForClobs = true; useGetStringForClobs = true;
@ -109,7 +106,7 @@ public class InformixDictionary
doubleTypeName = "NUMERIC(32,20)"; doubleTypeName = "NUMERIC(32,20)";
dateTypeName = "DATE"; dateTypeName = "DATE";
timeTypeName = "DATETIME HOUR TO SECOND"; timeTypeName = "DATETIME HOUR TO SECOND";
timestampTypeName = "DATETIME YEAR TO SECOND"; timestampTypeName = "DATETIME YEAR TO FRACTION(3)";
doubleTypeName = "NUMERIC(32,20)"; doubleTypeName = "NUMERIC(32,20)";
floatTypeName = "REAL"; floatTypeName = "REAL";
bigintTypeName = "NUMERIC(32,0)"; bigintTypeName = "NUMERIC(32,0)";
@ -133,7 +130,17 @@ public class InformixDictionary
// Informix doesn't support aliases in deletes if the table has an index // Informix doesn't support aliases in deletes if the table has an index
allowsAliasInBulkClause = false; 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) public void connectedConfiguration(Connection conn)
@ -190,7 +197,7 @@ public class InformixDictionary
throws SQLException { throws SQLException {
// informix actually requires that a boolean be set: it cannot // informix actually requires that a boolean be set: it cannot
// handle a numeric argument // handle a numeric argument
stmnt.setBoolean(idx, val); stmnt.setString(idx, val ? "t" : "f");
} }
public String[] getCreateTableSQL(Table table) { public String[] getCreateTableSQL(Table table) {
@ -256,4 +263,9 @@ public class InformixDictionary
} }
return conn; return conn;
} }
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
FilterValue start) {
throw new UnsupportedException();
}
} }