我有这样的疑问:
String hql ="FROM Appointment A WHERE "
+"(UNIX_TIMESTAMP(A.dateOfFirst) <= "+time+" AND ( (A.dateOfLast IS NULL) OR (UNIX_TIMESTAMP(A.dateOfLast) >= "+time+")))"
+"AND( "+time+" < UNIX_TIMESTAMP(A.dateOfFirst)+86400 OR" // Jeśli data jest datą początkową
+"(DAYOFMONTH(A.dateOfFirst) = "+day+" AND A.MontRepetition = TRUE) " miesiąca
+" OR ( MOD( "+time/86400+"- (to_days(A.dateOfFirst)-719528) , A.repetition) =0 ) "
+")";
插入日期13.09.2015后
FROM Appointment A WHERE (UNIX_TIMESTAMP(A.dateOfFirst) <= 1442141610 AND ( (A.dateOfLast IS NULL)
OR (UNIX_TIMESTAMP(A.dateOfLast) >= 1442141610)))AND( 1442141610 < UNIX_TIMESTAMP(A.dateOfFirst)+86400
OR(DAYOFMONTH(A.dateOfFirst) = 13 AND A.MonthRepetition = TRUE) OR ( MOD( 16691- (to_days(A.dateOfFirst)-719528) , A.repetition) =0 ) )
此查询应该返回此列:
id name dateOFFirst DateOfLast repetition MonthRepetition
'20', 'test6', '2015-09-12', '2015-09-25', '1', '0'
但不是。
当我只尝试这部分时:
FROM Appointment A WHERE UNIX_TIMESTAMP(A.dateOfFirst) <= 1442141610
AND ( (A.dateOfLast IS NULL) OR (UNIX_TIMESTAMP(A.dateOfLast) >= 1442141610) )
它不会返回此列
但是在MySQL Workbench中这个SQL:
SELECT * FROM calendar.appointments WHERE (UNIX_TIMESTAMP(date_of_first) <= 1442141610 AND ( date_of_last IS NULL OR UNIX_TIMESTAMP(date_of_last) > 1442141610))
返回该列。
我现在不知道为什么这个hql只返回“DateOfLast”
中的空行