You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Nathan Liang (JIRA)" <ji...@apache.org> on 2009/12/15 10:31:18 UTC

[jira] Commented: (OFBIZ-3245) Sandbox: Integrating The New Conversion Framework Into The Entity Engine

    [ https://issues.apache.org/jira/browse/OFBIZ-3245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12790630#action_12790630 ] 

Nathan Liang commented on OFBIZ-3245:
-------------------------------------

Hi,

Here is our workaround for the converter error when using oracle,  there are some hacks to get around that oracle driver returning non-standard object for JDBC type TIMESTAMP and DATE etc.


{noformat}
Index: framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
===================================================================
--- framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java	(revision 774)
+++ framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java	(working copy)
@@ -501,7 +501,7 @@
 
         Object sourceObject = null;
         try {
-            sourceObject = rs.getObject(ind);
+            sourceObject = getResultSetValue(rs, ind);
             if (sourceObject == null) {
                 entity.dangerousSetNoCheckButFast(curField, null);
                 return;
@@ -960,4 +960,30 @@
             addValueSingle(buffer, field, value, params);
         }
     }
+    
+    public static Object getResultSetValue(ResultSet rs, int index) throws SQLException {
+        Object obj = rs.getObject(index);
+        String className = null;
+        if (obj != null) {
+            className = obj.getClass().getName();
+        }
+        if (className != null &&
+                ("oracle.sql.TIMESTAMP".equals(className) ||
+                        "oracle.sql.TIMESTAMPTZ".equals(className))) {
+            obj = rs.getTimestamp(index);
+        } else if (className != null && className.startsWith("oracle.sql.DATE")) {
+            String metaDataClassName = rs.getMetaData().getColumnClassName(index);
+            if ("java.sql.Timestamp".equals(metaDataClassName) ||
+                    "oracle.sql.TIMESTAMP".equals(metaDataClassName)) {
+                obj = rs.getTimestamp(index);
+            } else {
+                obj = rs.getDate(index);
+            }
+        } else if (obj != null && obj instanceof java.sql.Date) {
+            if ("java.sql.Timestamp".equals(rs.getMetaData().getColumnClassName(index))) {
+                obj = rs.getTimestamp(index);
+            }
+        }
+        return obj;
+    }
 }

{noformat}


thanks,
Nathan

> Sandbox: Integrating The New Conversion Framework Into The Entity Engine
> ------------------------------------------------------------------------
>
>                 Key: OFBIZ-3245
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3245
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Adrian Crum
>            Assignee: Adrian Crum
>            Priority: Minor
>         Attachments: conversion.patch, conversion.patch, conversion.patch, conversion.patch, conversion.patch
>
>
> This issue contains a patch intended for evaluation before it is committed. See comments for details.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.