db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bouvet Konsulent" <bouvetk...@statnett.no>
Subject SV: Orcale, Criteria and Date
Date Tue, 19 Apr 2005 11:00:34 GMT
hello again list,
just to sum up here: Bernard's solution looked to be the best, but unfortunately I am working
towards version 8.1.7 of Oracle. And TIMESTAMP was not supported before version 9 :-(

Thomas' solution with using Criteria.CUSTOM, however, worked just fine :-)
This is the code I am now using:

private static long keeptime = 60 * 1000 * 10 ; //Ten minuttes
private static SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");

Object  o = DocumentPeer.CHANGED + " < "
+ "TO_DATE('"+sdf.format(new Date(System.currentTimeMillis() - keeptime))
+ "','DD.MM.YYYY HH:MI:SS')";
crit.add(DocumentPeer.CHANGED, o, Criteria.CUSTOM);

this generates the following SQL:
Current Query SQL (may not be complete or applicable): SELECT  FROM document WHERE document.CHANGED
< TO_DATE('18.02.2005 11:57:24','DD.MM.YYYY HH:MI:SS') AND document.IS_DELETED=1

Thank you for your help!

cheers,
pj

-----Opprinnelig melding-----
Fra: Thomas Fischer [mailto:fischer@seitenbau.net]
Sendt: 19. april 2005 10:58
Til: Apache Torque Users List
Emne: RE: Orcale, Criteria and Date






Hi,

I am not sure whether this is exactly the same thing, but there is a
related issue in the issue tracker:

http://issues.apache.org/scarab/issues/id/TRQS284

you might want to add a comment to that and describe your problem there.
Create a login in scarab and request a role as observer in the module
Torque>Source to do that.
However, this is not yet fixed in CVS.

As for a temporary workaround, you might try to use Criteria.CUSTOM (as I
just learned this morning). See

http://nagoya.apache.org/eyebrowse/ReadMsg?listName=torque-dev@db.apache.org&msgNo=4833

for details.
Unfortunately, this means to create DB-dependant code, but I do not see
another possibility at the moment :-(

   Thomas

"Bouvet Konsulent" <bouvetkons@statnett.no> schrieb am 19.04.2005 10:22:53:

> hello list,
> I have been given the task to move an existing application using
> Torque 3.1 from Postgres to Oracle. I am new to Torque, so I am
> sorry if this question is insulting anyone ;-)
> I have re-generated the databases with "torque.databse=oracle" in
> the build.properties-file, the jdbc-connection is working fine etc.
>
> I am running the following code:
>
> Criteria crit = new Criteria();
> crit.add(DocumentPeer.IS_DELETED, 1);
> Object  o = (new Date(System.currentTimeMillis() - keeptime).toString());
> //Object  o = sdf.format(new Date(System.currentTimeMillis() -
keeptime));
> crit.add(DocumentPeer.CHANGED, o, Criteria.LESS_THAN);
> log("Criteria="+crit+", o="+o+", keeptime="+keeptime);
> DocumentPeer.doDelete(crit);
>
> which generates the following output:
>
> 2005-04-19 10:08:14,258 INFO  [org.jboss.web.localhost.Engine]
> StandardContext[/mywebapp]Criteria=Criteria:: document.
> CHANGED<=>document.CHANGED<'18.02.2005 09:08:14':  document.
> IS_DELETED<=>document.IS_DELETED=1:
> Current Query SQL (may not be complete or applicable): SELECT  FROM
> document WHERE document.CHANGED<'18.02.2005 09:08:14' AND document.
> IS_DELETED=1, o=18.02.2005 09:08:14, keeptime=5184000000
> 2005-04-19 10:08:14,265 ERROR [org.jboss.web.localhost.Engine]
> StandardContext[/mywebapp]IndexWorkerServlet:WorkerThread:
> updateFiles() :Unable to delete files
> java.sql.SQLException: ORA-01830: date format picture ends before
> converting entire input string
>
> I understand that Oracle does not like the date-format here, and if
> I were to run directly towards an Oracle database, I would use the
> TO_DATE function like this:
> TO_DATE('18.04.2005 09:08:14','DD.MM.YYYY HH.MI.SS')
>
> However, I am not able to do this here, as I thought Torque would
> take care of everything for me!?
> I see that Criteria also has an addDate-function, but this does not
> give me the option of adding time of day, only day, month and year.
>
> If anyone has a solution, I would highly appreciate it!
>
> /pj
>
>
>
> Statnett SF, Tel. head office +47 22527000, Enterprise No. NO 962
> 986 633 VAT, www.statnett.no, firmapost@statnett.no
> _________________________________________________________________
>
> This e-mail and any attached files are confidential and may be
> legally privileged. If you have received this transmission in error
> please notify the sender by reply e-mail immediately and then delete
> the e-mail.
> E-mail transmission cannot be guaranteed to be secure or error free
> as information could be intercepted, corrupted, lost, destroyed,
> arrive late or incomplete. If verification is required please
> request a hard copy version. This e-mail message has been virus
> checked by the virus programs used by Statnett SF.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org




Statnett SF, Tel. head office +47 22527000, Enterprise No. NO 962 986 633 VAT, www.statnett.no,
firmapost@statnett.no
_________________________________________________________________

This e-mail and any attached files are confidential and may be legally privileged. If you
have received this transmission in error please notify the sender by reply e-mail immediately
and then delete the e-mail.
E-mail transmission cannot be guaranteed to be secure or error free as information could be
intercepted, corrupted, lost, destroyed, arrive late or incomplete. If verification is required
please request a hard copy version. This e-mail message has been virus checked by the virus
programs used by Statnett SF.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message