Oracle SQL DATE conversion problem using iBATIS via Java JDBC

前端 未结 7 548
悲哀的现实
悲哀的现实 2020-12-24 03:36

I\'m currently wrestling with an Oracle SQL DATE conversion problem using iBATIS from Java.

Am using the Oracle JDBC thin driver ojdbc14 version 10.2.0.4.0. iBATIS v

相关标签:
7条回答
  • 2020-12-24 04:19

    Yes, I see - the plain SQL DATE standard must be to only store to day resolution. Indeed, here is a snippet on Oracle's DATE type:

    Oracle supports both date and time, albeit differently from the SQL2 standard. Rather than using two separate entities, date and time, Oracle only uses one, DATE. The DATE type is stored in a special internal format that includes not just the month, day, and year, but also the hour, minute, and second.

    Which makes the point that Oracle's DATE exceeds standard SQL DATE.

    Hmm, Oracle PL/SQL folks use DATE extensively to hold values where they depend on the resolution being to the second. Looks like iBATIS needs something like the Hibernate sql dialect concept where instead of interpreting DATE via java.sql.Date, could override and instead interpret via java.util.Date, which Javadocs defines as permitting millisecond resolution.

    Unfortunately when I've changed the mapping to something like:

    <result property="from_date" jdbcType="DATE" javaType="java.util.Date"/>
    

    or

    <result property="from_date" jdbcType="DATETIME" javaType="java.util.Date"/>
    

    It's still seemingly first translated the SQL DATE to a java.sql.Date and lost the time of day precision.

    0 讨论(0)
提交回复
热议问题