[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-1052) Allow CalendarType.set to accept Date objects

Steve Ebersole (JIRA) noreply at atlassian.com
Mon Mar 21 13:01:15 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-1052.
-------------------------------


Closing stale resolved issues

> Allow CalendarType.set to accept Date objects
> ---------------------------------------------
>
>                 Key: HHH-1052
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1052
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.1 rc 1
>         Environment: Hibernate 3.1RC1, MySQL 4.1, Windows XP
>            Reporter: Adam Greene
>            Priority: Minor
>   Original Estimate: 5m
>  Remaining Estimate: 5m
>
> CalendarType.set expects only Calendar objects as input.  But when you are building Criterias with complex requirements, you many times use a Calendar object to do the calculations, and it would be nice to be able to pass Calendar.getTime() (which returns java.util.Date) to the Restrictions methods, because otherwise you end up passing the same Calendar object two seperate calls and you change the values in between calls, resulting in possible unexpected behaviour.
> Example (though a bit contrived does show what I am talking about):
> Calendar startcal = Calendar.getInstance();
> Calendar endcal = Calendar.getInstance();
> startcal.set(Calendar.DAY_OF_MONTH, 1);
> endcal.set(Calendar.DAY_OF_MONTH, 10);
> Criterion startin = Restrictions.between("start", startcal, endcal);
> startcal.set(Calendar.DAY_OF_MONTH, 10);
> endcal.set(Calendar.DAY_OF_MONTH, 30);
> Criterion endin = Restrictions.between("end", startcal, endcal);
> This might cause unexpected behaviour, but :
> Criterion startin = Restrictions.between("start", startcal.getTime(), endcal.getTime());
> startcal.set(Calendar.DAY_OF_MONTH, 10);
> endcal.set(Calendar.DAY_OF_MONTH, 30);
> Criterion endin = Restrictions.between("end", startcal.getTime(), endcal.getTime());
> would not cause problems.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list