HQL是否具有与SQL COVERT()函数等效的功能

时间:2019-01-28 06:15:27

标签: hibernate hql

我正在使我们的SQL查询适应hql,但是当我们的查询之一使用CONVERT()函数时遇到了障碍。我在网上找不到有关hql的任何信息。

查询:

"SELECT tse.id, tse.ts_entries_ParentID As ParentID, tse.hours, 

                            tse.project As projectID, (SELECT CONCAT(Project_Pastel_Prefix, ' - ', Project_Description) FROM Project WHERE Project_Code = tse.project) As 'projectName',
                            tse.task As taskID, (SELECT Budget FROM TimesheetCategories WHERE id = tse.task) As 'taskName',
                            tse.task As oldTaskID, (SELECT name FROM ts_tasks WHERE id = tse.task) As 'oldTaskName',

                            IF(STRCMP(tse.comment,'') = 0, (SELECT CONCAT(Project_Pastel_Prefix, ' - ', Project_Description) FROM Project WHERE Project_Code = tse.project), tse.comment) As 'text', 
                            tse.user As userID, tse.customer As customerID,
                            concat(tsw.ts_working_hours_Date, ' ',tsw.ts_working_hours_Time_Start) As startDate, concat(tsw.ts_working_hours_Date, ' ',tsw.ts_working_hours_Time_End) As endDate,
                            CONVERT(1, UNSIGNED) As TypeId,
                            if(tsw.ts_working_hours_Date BETWEEN '1994-01-01' AND '2018-03-31', 2, 1) as TemplateID,

                            0 AS 'days',
                            0 AS 'isDoc',
                            '0' AS 'authorised',
                            tse.comment AS 'description',
                            0 AS 'leaveType',
                            0 AS 'isApproved'

                            FROM ts_entries tse, ts_working_hours tsw
                            WHERE tse.ts_entries_ParentID = tsw.ts_working_hours_ID
                            AND tse.user = :userID
                            AND tsw.ts_working_hours_Date BETWEEN ':startDate' AND ':endDate'

1 个答案:

答案 0 :(得分:2)

您可以将 cast 功能用作

cast(1 as UNSIGNED)