db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Fortytwo <...@ign.com>
Subject RE: Torque 3.0 Oracle 8i and Dates
Date Thu, 13 Feb 2003 22:58:18 GMT
I can't tell for certain if this is exactly the problem, but when I first 
started using Torque I had problems doing selects or inserts (can't 
remember which) with dates. The solution was to force everything to always 
use prepared statements instead of normal sql queries.

To do this, I added an ant replace task to the a ant task that I use to 
generate the torque files.
It replaces all instance of "BasePeer.doSelect" with "BasePeer.doPSSelect".

(I describe this in my torque faq at 
http://g42.org/programming/torque/TorqueHowto.html)

Here's the ant task that does the replace:
<replace dir="WEB-INF/classes/com/snowball/gamerprof/om">
<include name="**/*.java" />
<replacetoken>BasePeer.doSelect(criteria)</replacetoken>
<replacevalue>BasePeer.doPSSelect(criteria,dbCon)</replacevalue>
</replace>


At 01:18 PM 2/13/2003, you wrote:
>Well, I'm going to answer myself in the hopes that this helps someone else,
>my null pointer exception was solved by adding
>torque.database.default.adapter=oracle to my torque.properties file.
>
>That brought to light a whole new suite of problems with using Dates in
>Criteria with Oracle.  After wading through the source for a while, I've
>fixed the problem by adding the following to
>org.apache.torque.adapter.DBOracle.java:
>
>private static final String DATE_FORMAT = "dd-MM-yyyy HH:mm:ss";
>public String getDateString(Date date) {
>   return "TO_DATE('" + new SimpleDateFormat(DATE_FORMAT).format(date) + "',
>'DD-MM-YYYY HH24:MI:SS')";
>}
>
>Essentially, since DBOracle didn't override getDateString(String), the one
>from DB was being used - which is completely useless as far as Oracle is
>concerned.  Actually it's beyond buggy, because it doesn't take into account
>the fact that Timestamp objects cannot represent dates before 01-Jan-1970.
>
>Anyway, I think my solution should work (it works for us, so far).  What is
>the process of forwarding this as a suggestion to the Torque developers?
>Torque is still being actively maintained, right?
>
>Thanks,
>--
>Voytek Jarnot
>Quidquid latine dictum sit, altum viditur.


Mime
View raw message