• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Hibernate date in criteria

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I've developed an application that simply pulls records from the DB out, and allows the user to select the date/time range to choose from (along with a bunch of other criteria). This has worked really well up till recently when the DB server (SQL Server 2005) was physically changed to one in another location.

Below is the criteria I'm using:

(I'm not using 'between' as either end of the limit is optional)

I've also been able to run SQL queries like this:
(for March 4th)

When we moved to the new DB server I found the application stopped returning correct results.

I'm no expert here, but I'm guessing the locale of the new server is different, and I've needed to specify the month and day switched around
(for March 4th)
I've confirmed that this is returning March 4th by doing a CONVERT on created_datetime on the returned results.

I would've thought that Hibernate would've been able to abstract me from this change. However, I confirmed that by turning on show_sql that:


This would mean "2011-03-04 xx:xx:xx" is being used in the SQL to the new DB server, which means April 3rd to the DB server instead of March 4th (imagine the irony - we changed the server yesterday, March 3rd, so this didn't show up!!)

Is there a way for Hibernate to use a 'standard' format? I can confirm that if I was able to send something like "2011-03-04T23:59:59" then both servers will interpret this as March 4th.

Have I misunderstood/misused something?
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic