Bug 1023994

Summary: java.util.Calendar conversion to java.util.Date fails - HHH-8643
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Gary Hu <ghu>
Component: HibernateAssignee: Brett Meyer <brmeyer>
Status: CLOSED CURRENTRELEASE QA Contact: Zbyněk Roubalík <zroubali>
Severity: low Docs Contact: Russell Dickenson <rdickens>
Priority: low    
Version: 6.1.0CC: jmartisk, kkhan, sgilda, smumford, theute
Target Milestone: DR2   
Target Release: EAP 6.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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 14:38:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1024864, 1063408    

Description Gary Hu 2013-10-28 14:26:48 UTC
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 14:39:05 UTC
Recommend EAP 6.3.0 -- low priority issue with a simple workaround.

Comment 2 Brett Meyer 2013-10-28 16:52:22 UTC
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 10:11:37 UTC
Verified with EAP 6.3.0.ER1 / hibernate-entitymanager 4.2.11.Final-redhat-1

Comment 4 sgilda 2014-05-12 19:46:35 UTC
Changed <literal></literal> tags in Doc Text to ticks (`) to fix Bug 1096865