Author: jolee
Date: 2013-10-22 10:52:13 -0400 (Tue, 22 Oct 2013)
New Revision: 4605
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/BaseDB2ExecutionFactory.java
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
Log:
TEIID-2704: DB2 sql/xml values must be read inline
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/BaseDB2ExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/BaseDB2ExecutionFactory.java 2013-10-22
14:52:04 UTC (rev 4604)
+++
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/BaseDB2ExecutionFactory.java 2013-10-22
14:52:13 UTC (rev 4605)
@@ -21,20 +21,23 @@
*/
package org.teiid.translator.jdbc.db2;
-
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
+import org.teiid.language.Comparison.Operator;
import org.teiid.language.DerivedColumn;
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.Join;
+import org.teiid.language.Join.JoinType;
import org.teiid.language.LanguageFactory;
import org.teiid.language.LanguageObject;
import org.teiid.language.Limit;
import org.teiid.language.Literal;
-import org.teiid.language.Comparison.Operator;
-import org.teiid.language.Join.JoinType;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TranslatorException;
@@ -178,4 +181,21 @@
return false;
}
+ @Override
+ public Object retrieveValue(ResultSet results, int columnIndex,
+ Class<?> expectedType) throws SQLException {
+ if (expectedType == TypeFacility.RUNTIME_TYPES.XML) {
+ return results.getString(columnIndex);
+ }
+ return super.retrieveValue(results, columnIndex, expectedType);
+ }
+
+ @Override
+ public Object retrieveValue(CallableStatement results, int parameterIndex,
+ Class<?> expectedType) throws SQLException {
+ if (expectedType == TypeFacility.RUNTIME_TYPES.XML) {
+ return results.getString(parameterIndex);
+ }
+ return super.retrieveValue(results, parameterIndex, expectedType);
+ }
}
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2013-10-22
14:52:04 UTC (rev 4604)
+++
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2013-10-22
14:52:13 UTC (rev 4605)
@@ -150,5 +150,4 @@
}
});
}
-
}
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2013-10-22
14:52:04 UTC (rev 4604)
+++
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2013-10-22
14:52:13 UTC (rev 4605)
@@ -23,11 +23,16 @@
package org.teiid.translator.jdbc.derby;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.LanguageObject;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
import org.teiid.translator.jdbc.db2.BaseDB2ExecutionFactory;
import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
@@ -184,5 +189,20 @@
public boolean supportsRowLimit() {
return this.getDatabaseVersion().compareTo(TEN_5) >= 0;
}
-
-}
+
+ @Override
+ public List<?> translate(LanguageObject obj, ExecutionContext context) {
+ if (obj instanceof DerivedColumn) {
+ DerivedColumn selectSymbol = (DerivedColumn)obj;
+
+ if (selectSymbol.getExpression().getType() == TypeFacility.RUNTIME_TYPES.XML) {
+ if (selectSymbol.getAlias() == null) {
+ return Arrays.asList("XMLSERIALIZE(", selectSymbol.getExpression(), "
AS CLOB)"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ //we're assuming that alias quoting shouldn't be needed
+ return Arrays.asList("XMLSERIALIZE(", selectSymbol.getExpression(), "
AS CLOB) AS ", selectSymbol.getAlias()); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+ return super.translate(obj, context);
+ }
+}
\ No newline at end of file
Modified:
branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
---
branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2013-10-22
14:52:04 UTC (rev 4604)
+++
branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2013-10-22
14:52:13 UTC (rev 4605)
@@ -71,5 +71,4 @@
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
TRANSLATOR);
}
-
}