1
我無法弄清楚這一點。「SELECT」附近的SQLException語法不正確
這個查詢運行SQLSERVER中沒有錯誤:
SELECT COUNT(tjmm.MAINMISSION_PARTICIPANT_SID)
FROM T_MOVEMENT_LEG ml INNER JOIN
TJ_MVLG_PARTMOV tjmp ON ml.MOVEMENTLEG_SID = tjmp.MOVEMENTLEG_SID INNER JOIN
T_MAIN_MISSION mm INNER JOIN
T_MISSION_PARTICIPANTS mp ON mm.DETCO_MISSIONPARTICIPANT_SID = mp.MISSION_PARTICIPANT_SID INNER JOIN
T_PARTICIPANT_MOVEMENT pm ON mp.MISSION_PARTICIPANT_SID = pm.MISSION_PARTICIPANT_SID INNER JOIN
TJ_MMIS_MISPART tjmm ON mm.MAINMISSION_SID = tjmm.MAINMISSION_SID AND
mp.MISSION_PARTICIPANT_SID = tjmm.MISSION_PARTICIPANT_SID ON
tjmp.PARTICIPANTMOVEMENT_SID = pm.PARTICIPANTMOVEMENT_SID
WHERE (mm.IN_USE = 1) AND (mp.IS_OPS = 1) AND (pm.IS_OPS = 1) AND
(ml.LEGEFFECTIVE_STARTDATE < { fn NOW() }) AND (ml.LEGEFFECTIVE_ENDDATE > { fn NOW() }) AND
(ml.IS_CANCELED = 0)
它轉化到@Formula:
@Formula("select count(tjmm.MAINMISSION_PARTICIPANT_SID) "
+ "FROM T_MOVEMENT_LEG ml INNER JOIN "
+ "TJ_MVLG_PARTMOV tjmp ON ml.MOVEMENTLEG_SID = tjmp.MOVEMENTLEG_SID INNER JOIN "
+ "T_MAIN_MISSION mm INNER JOIN "
+ "T_MISSION_PARTICIPANTS mp ON mm.DETCO_MISSIONPARTICIPANT_SID = mp.MISSION_PARTICIPANT_SID INNER JOIN "
+ "T_PARTICIPANT_MOVEMENT pm ON mp.MISSION_PARTICIPANT_SID = pm.MISSION_PARTICIPANT_SID INNER JOIN "
+ "TJ_MMIS_MISPART tjmm ON mm.MAINMISSION_SID = tjmm.MAINMISSION_SID AND "
+ "mp.MISSION_PARTICIPANT_SID = tjmm.MISSION_PARTICIPANT_SID ON "
+ "tjmp.PARTICIPANTMOVEMENT_SID = pm.PARTICIPANTMOVEMENT_SID "
+ "WHERE (mm.IN_USE = 1) AND (mp.IS_OPS = 1) AND (pm.IS_OPS = 1) AND "
+ "tjmm.MainMission_SID = MainMission_SID AND"
+ "(ml.LEGEFFECTIVE_STARTDATE < NOW()) AND (ml.LEGEFFECTIVE_ENDDATE > NOW()) AND "
+ "(ml.IS_CANCELED = 0)")
private Integer opsCount;
改變了NOW()
並添加鏈接到該POJO編號:tjmm.MainMission_SID = MainMission_SID
任何人都知道我在公式中有什麼缺點?
我看到你在年底錯過了空間問題:+「tjmm.MainMission_SID = MainMission_SID AND」 – Pienterekaak 2014-10-06 15:31:10
@Pienterekaak aargg,無法測試到明天但這確實是一個很好的候選人,謝謝 – chillworld 2014-10-06 15:32:38