mirror of https://github.com/apache/openjpa.git
OPENJPA-908 - Commit contribution by Tim McConnell.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@777615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
056d211658
commit
6d91126dd6
|
@ -21,6 +21,8 @@ package org.apache.openjpa.jdbc.sql;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -32,6 +34,7 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||
|
@ -550,15 +553,58 @@ public class PostgresDictionary
|
|||
super.setClobString(stmnt, idx, val, col);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the getOjbect() method to handle the case where the latest
|
||||
* Postgres JDBC driver returns a org.postgresql.util.PGobject instead of a
|
||||
* java.sql.Timestamp
|
||||
*
|
||||
* @param rs
|
||||
* @param column
|
||||
* @param map
|
||||
*
|
||||
* @return
|
||||
* @exception SQLException
|
||||
*/
|
||||
public Object getObject(ResultSet rs, int column, Map map)
|
||||
throws SQLException {
|
||||
Object obj = super.getObject(rs, column, map);
|
||||
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
if (obj.getClass().getName().equals("org.postgresql.util.PGobject")) {
|
||||
try {
|
||||
Method m = obj.getClass().getMethod("getType", (Class[]) null);
|
||||
Object type = m.invoke(obj, (Object[]) null);
|
||||
if (((String) type).equalsIgnoreCase(timestampTypeName)) {
|
||||
return rs.getTimestamp(column);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof InvocationTargetException)
|
||||
t = ((InvocationTargetException) t).getTargetException();
|
||||
if (t instanceof SQLException)
|
||||
throw (SQLException) t;
|
||||
throw new SQLException(t.getMessage());
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append XML comparison.
|
||||
*
|
||||
* @param buf the SQL buffer to write the comparison
|
||||
* @param op the comparison operation to perform
|
||||
* @param lhs the left hand side of the comparison
|
||||
* @param rhs the right hand side of the comparison
|
||||
* @param lhsxml indicates whether the left operand maps to XML
|
||||
* @param rhsxml indicates whether the right operand maps to XML
|
||||
* @param buf
|
||||
* the SQL buffer to write the comparison
|
||||
* @param op
|
||||
* the comparison operation to perform
|
||||
* @param lhs
|
||||
* the left hand side of the comparison
|
||||
* @param rhs
|
||||
* the right hand side of the comparison
|
||||
* @param lhsxml
|
||||
* indicates whether the left operand maps to XML
|
||||
* @param rhsxml
|
||||
* indicates whether the right operand maps to XML
|
||||
*/
|
||||
public void appendXmlComparison(SQLBuffer buf, String op, FilterValue lhs,
|
||||
FilterValue rhs, boolean lhsxml, boolean rhsxml) {
|
||||
|
@ -577,8 +623,10 @@ public class PostgresDictionary
|
|||
/**
|
||||
* Append XML column value so that it can be used in comparisons.
|
||||
*
|
||||
* @param buf the SQL buffer to write the value
|
||||
* @param val the value to be written
|
||||
* @param buf
|
||||
* the SQL buffer to write the value
|
||||
* @param val
|
||||
* the value to be written
|
||||
*/
|
||||
private void appendXmlValue(SQLBuffer buf, FilterValue val) {
|
||||
Class rc = Filters.wrap(val.getType());
|
||||
|
|
Loading…
Reference in New Issue