Bug 1023994 - java.util.Calendar conversion to java.util.Date fails - HHH-8643
java.util.Calendar conversion to java.util.Date fails - HHH-8643
Status: CLOSED CURRENTRELEASE
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate (Show other bugs)
6.1.0
Unspecified Unspecified
low Severity low
: DR2
: EAP 6.3.0
Assigned To: Brett Meyer
Zbyněk Roubalík
Russell Dickenson
:
Depends On:
Blocks: 1024864 1063408
  Show dependency treegraph
 
Reported: 2013-10-28 10:26 EDT by Gary Hu
Modified: 2015-09-01 00:00 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
This release of JBoss EAP 6 contains a fix to a bug in the Hibernate component that caused an `IllegalArgumentException` to be thrown when setting a `TemooralType.DATE` or `TemporalType.TIMESTAMP` parameter in a JPA query. The parameter is intended to be able to use a Calendar or a Date value, however this interchangeability did not operate as expected. The issue has now been corrected and the exception no longer presents when using `TemporalType` parameters in queries.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-08-06 10:38:43 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Gary Hu 2013-10-28 10:26:48 EDT
When using java.util.Calendar in a query to retrieve an entity class containing a field of java.util.Date type it throws exceptions:

Caused by: java.lang.IllegalArgumentException: Parameter value [java.util.GregorianCalendar[time=1382561831603,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2013,MONTH=9,WEEK_OF_YEAR=43,WEEK_OF_MONTH=4,DAY_OF_MONTH=23,DAY_OF_YEAR=296,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=57,SECOND=11,MILLISECOND=603,ZONE_OFFSET=-21600000,DST_OFFSET=3600000]] did not match expected type [java.util.Date]
at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:375) [hibernate-entitymanager-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:348) [hibernate-entitymanager-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:419) [hibernate-entitymanager-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:73) [hibernate-entitymanager-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.jboss.as.jpa.container.QueryNonTxInvocationDetacher.setParameter(QueryNonTxInvocationDetacher.java:142) [jboss-as-jpa-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]

The same code worked fine in EAP 5 with Hibernate 3.

Please check https://hibernate.atlassian.net/browse/HHH-8643 for all of the details.
Comment 1 Brett Meyer 2013-10-28 10:39:05 EDT
Recommend EAP 6.3.0 -- low priority issue with a simple workaround.
Comment 2 Brett Meyer 2013-10-28 12:52:22 EDT
Pushed upstream and http://git.app.eng.bos.redhat.com/hibernate/hibernate-core.git/log/?h=eap62-updates (in case there is another 6.2 build for some reason).
Comment 3 Jan Martiska 2014-04-16 06:11:37 EDT
Verified with EAP 6.3.0.ER1 / hibernate-entitymanager 4.2.11.Final-redhat-1
Comment 4 sgilda 2014-05-12 15:46:35 EDT
Changed <literal></literal> tags in Doc Text to ticks (`) to fix Bug 1096865

Note You need to log in before you can comment on or make changes to this bug.