openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Vorburger" <mvorbur...@odyssey-group.com>
Subject RE: current_date and persistent date field
Date Tue, 09 Sep 2008 17:49:09 GMT
Hello, Marc and Jeremy, others:

> I've been searching for a means to do something similar with JPQL but
haven't found anything yet

I'm wondering if the "SQL passthrough" extenion, see
http://n2.nabble.com/Queries-using-specific-SQL,-e.g.-functions,-or-spec
ific-operators---passthrough-SQL-pieces-without-full-native-query-td6688
56.html, could interest you?

> Can one do this with custom functions in OpenJPA ?

May be one could write your own JDBCFilterListener for a need like this?

It would be nice if this area was better documented...

Regards,
Michael
 

-----Original Message-----
From: Jeremy Bauer [mailto:techhusky@gmail.com] 
Sent: jeudi, 4. septembre 2008 21:14
To: users@openjpa.apache.org
Subject: Re: current_date and persistent date field

Marc,

It isn't very elegant, but you could try using a native query with a
cast to produce the result.  I was able to get the native query below to
produce only Orders for the current date using DB2. My 'created'
field is defined as a TIMESTAMP, which is similar to the DATETIME
datatype.

@NamedNativeQuery(name="todaysOrders",
        query="select * from ORDER where CAST(created AS DATE) =
current_date",
        resultClass=Order.class)

This is, of course, DB specific so it may or may not work for with your
DB (SQL Server?).  I've been searching for a means to do something
similar with JPQL but haven't found anything yet.

-Jeremy

____________________________________________________________

 This email and any files transmitted with it are CONFIDENTIAL and intended
  solely for the use of the individual or entity to which they are addressed.
 Any unauthorized copying, disclosure, or distribution of the material within
  this email is strictly forbidden.
 Any views or opinions presented within this e-mail are solely those of the
  author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
 An electronic message is not binding on its sender. Any message referring to
  a binding engagement must be confirmed in writing and duly signed.
 If you have received this email in error, please notify the sender immediately
  and delete the original.

Mime
View raw message