cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrus Adamchik (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (CAY-1323) oracle.sql.TIMESTAMP in Result of query
Date Fri, 04 Dec 2009 16:06:21 GMT

     [ https://issues.apache.org/jira/browse/CAY-1323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andrus Adamchik reassigned CAY-1323:
------------------------------------

    Assignee: Evgeny Ryabitskiy  (was: Andrus Adamchik)

Cool. Assigning this to Evgeny.

Good stuff. See my comments inline below...


Index: src/main/java/org/apache/cayenne/access/types/UtilDateType.java
===================================================================
-    public Object materializeObject(ResultSet rs, int index, int type) throws Exception {
+    public Date materializeObject(ResultSet rs, int index, int type) throws Exception {
         Date val = null;
 
         switch (type) {
@@ -70,28 +69,18 @@
                 val = rs.getTime(index);
                 break;
             default:
-                // here the driver can "surprise" us
-                // check the type of returned value...
-                Object object = rs.getObject(index);
-
-                if (object != null && !(object instanceof Date)) {
-                    throw new CayenneRuntimeException(
-                            "Expected an instance of java.util.Date, instead got "
-                                    + object.getClass().getName()
-                                    + ", column index: "
-                                    + index);
-                }
-
-                val = (Date) object;
+                val = rs.getDate(index);
                 break;
         }

[Andrus] Not a bad idea, however 'getDate' would lose all time data, so what if that weird
object returned by the driver is a custom timestamp... Should we call 'getTimestamp()' instead?
Something to figure out.


Index: src/main/java/org/apache/cayenne/dba/oracle/OracleTimestampType.java
===================================================================
+
+/**
+ * This is handler for Oracle specific type "oracle.sql.TIMESTAMP"
+ * Oracle official JDBC Driver is mapping SQL TIMESTAMP to this type
+ * Created to solve CAY-1323.
+ */
+public class OracleTimestampType extends TimestampType {
+
+    @Override
+    public String getClassName() {
+        return "oracle.sql.TIMESTAMP";
+    }
+}

[Andrus] This is a new use pattern of ExtendedTypes (till now 'materializeObject' would always
return the same class or a subclass of 'getClassName'... I guess it's fine to trick Oracle.
Also Oracle has a few more odd types:

http://download-east.oracle.com/otn_hosted_doc/jdeveloper/904preview/jdbc-javadoc/oracle/sql/package-summary.html

that we may want to handle in a similar fashion (at least the date/time ones)

> oracle.sql.TIMESTAMP in Result of query
> ---------------------------------------
>
>                 Key: CAY-1323
>                 URL: https://issues.apache.org/jira/browse/CAY-1323
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 2.0.5, 3.0 beta 1
>            Reporter: Evgeny Ryabitskiy
>            Assignee: Evgeny Ryabitskiy
>         Attachments: CAY-1323_3.1.patch, CAY-1323_3.1_OracleTest.patch, cayenne.xml,
OracleTimestampTest.java, OracleTimestampTestMap.map.xml
>
>
> Result of query from column of timestamp type was mapped to oracle.sql.TIMESTAMP.
> I think it should be mapped to standard JDBS TIMESTAMP
> I am using latest official Oracle JDBC driver.

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


Mime
View raw message