We're updating the issue view to help you get more done. 

Unexpected (changed) behavior of @Temporal(TemporalType.DATE) columns

Description

Hi there,

first of all, thanks for your continuing work for hibernate.

Hibernate 4.2.6 shows a new behavior regarding the handling of

@Temporal(TemporalType.DATE)
private Calendar refDate;

columns.

Prior to 4.2.6 the seems to be handled like:

  • Take the date from the database and treat it like midnight

  • Then convert it to the userTimezone

Now it seems to bee

  • Take the date from the database and treat it like midnight

  • Then convert it to the userTimezone

  • Strip the time

This results in a calendar with a very different value than before. Technically it's probably more correct, but apart from breaking stuff, it's quite a different and unexpected behavior than @Temporal(TemporalType.TIMESTAMP) columns.

A result from 4.2.5 and prior for a date column with the value '2013-10-15' was
// Hibernate 4.2.5
// Tue Oct 15 02:00:00 CEST 2013
that can be correctly converted to a Joda Local Date with forced UTC timezone using
new LocalDate(foobar.getRefDate(), ISOChronology.getInstanceUTC())
resulting in exactly 2013-10-15

Now hibernate 4.2.6 returns:
// Hibernate 4.2.6
// Tue Oct 15 00:00:00 CEST 2013

This is quite different date.

I'd vote to restore the old way as it is consistent with the conversion in TIMESTAMP columns.

At least the changed should have been in the release notes as it is very likely to break stuff.

I've created a little test case. You'll need a mysql datebase hibernate_tests for it.

https://github.com/michael-simons/possible_hibernate_426_bug_with_date

Thanks in advance.

Environment

Java 7, user.timeZone "Europe/Berlin", MySQL with UTC timezone

Status

Assignee

Brett Meyer

Reporter

Michael Simons

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

4.2.6

Priority

Major