Rob,

I don't have any answers for you, but if I was debugging it I would  
try two things:

1) Put a breakpoint in PersistentLocalDate.nullSafeSet() as from what  
I understand Hibernate would use that method to set the dates in the  
query's prepared statement.  Perhaps what goes on in that method will  
provide some clues.
2) Temporarily change your code to use LocalDateTime instead of  
LocalDate and see what the generated query looks like.  If there's  
some unexpected timezone conversion going on, the times should show  
you that.

Good luck,
Jim

On Dec 11, 2007, at 8:57 PM, Rob Hills wrote:

> Hi All,
>
> I am developing an app using AppFuse 2.0 with Hibernate and Struts 2.
> I've just finished refactoring it to use Joda-time components and I
> really like their clean functionality, thanks for all the effort  
> that's
> gone in so far.
>
> I'm having a problem with searching date fields in the database
> however.  It's hard to know if it's a Joda-time issue or a Hibernate
> issue, but hopefully folks here can help me work that out.
>
> The application I'm developing will only ever be run within the one
> timezone - here in Western Australia (UMT + 9 with summertime).   
> One of
> the reasons I introduced Joda-time was to help eliminate some unwanted
> timezone issues I was getting with java.util.Date.
>
> So, I elected to use joda LocalDate, LocalTime and LocalDateTime types
> throughout my application, believing that would eliminate my TZ- 
> related
> problems.  It seems to have done that, with one exception.
>
> When I query the Database via Hibernate, there seems to be some  
> sort of
> date adjustment happening that I am assuming is TZ related.
>
> I am building my query using Hibernate's Criteria class.  I set my  
> date
> criteria as follows:
>
> criteria.add(Expression.between("departureDate", startDate, endDate);
>
> where "departureDate" refers to a POJO attribute that has been defined
> using the appropriate @Type annotation as a PersistentLocalDate and
> "startDate" and "endDate" are LocalDate variables.
>
> My problem is that when I execute this query, the dates are being
> "shifted left" by one day.  For example, if I'm searching for dates
> between today (12 Dec here) and 7 days hence (19 Dec), I find that the
> query Hibernate executes has the parameter values '11 December  
> 2007' and
> '18 December 2007' respectively.  I've traced the code and confirmed
> that at the point of adding the criteria (via the code snipped above)
> the 'startDate' and 'endDate' values are correct (looking at them via
> the Eclipse debugger).
>
> Can anyone explain to me why this is happening and how I can stop it
> from happening?
>
> In case it's relevant, my development db is Postgres and the relevant
> column has been defined as type "date" (created programmatically by
> Maven using Hibernate's hbm2ddl goal).  FWIW, my Test and Prod DBs are
> Oracle, but I've not got to the point of deploying to the Test  
> platform yet.
>
> TIA,
> Rob Hills
> Waikiki, Western Australia
>
>
> ---------------------------------------------------------------------- 
> ---
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest


-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to