[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2967) Cast to date in Formula still doesn't work

Arturo Frappé (JIRA) noreply at atlassian.com
Wed Mar 25 15:36:38 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32715#action_32715 ] 

Arturo Frappé commented on HHH-2967:
------------------------------------

As Michael Pätzold says, it seems that are missing keywords in SybaseDialect 

To address this exlcusive situation, where you have a formula with CONVERT(DATETIME, ....) I suggest add the offending keyword to the list of keywords in the corresponding Dialect class.

I'll put a patch as example.

> Cast to date in Formula still doesn't work
> ------------------------------------------
>
>                 Key: HHH-2967
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2967
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria, query-hql, query-sql
>    Affects Versions: 3.2.5
>         Environment: Hibernate-Version: 3.2.5.ga
> Oracle 9i/10g
>            Reporter: Frederic Leitenberger
>            Priority: Minor
>         Attachments: testcase.jar
>
>
> Similar to HHH-473.
> Oracle 10g supports trunc(TS). (TS is a timestamp)
> Oracle 9i only supports trunc(cast(TS as date)) [and 10g supports this still too].
> Therefore i need to add the cast to the Forumla.
>     @Basic
>     @Column(nullable = false, updatable = false)
>     @Temporal(TemporalType.TIMESTAMP)
>     public Date getCreated() {
>         return created;
>     }
>     public void setCreated(Date created) {
>         this.created = created;
>     }
>     @Formula(value = "trunc(cast(created as date))")
>     public Date getDate() {
>         return date
>     }
>     public void setDate(Date date {
>         this.date= date
>     }
> This results in the following query:
> select
>         eventlog0_.id as id9_0_,
>         eventlog0_.created as created9_0_,
>         .........
>         trunc(cast(eventlog0_.created as eventlog0_.date)) as formula6_0_
>     from
>         ICCS6.EventLog eventlog0_
>     where
>         eventlog0_.id=?
> The alias in front of "date" is obviously misplaced there.
> I also tried renaming the formula (since it was called "date"), but this didn't change the result.

-- 
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