0

请建议,我正在使用 ibatis ORM 从 postgres 数据库中检索数据。

当我使用 ibatis 触发以下查询时,时间戳“PVS.SCHED_DTE”会减少到“2013-06-07 23:30:00.0”,其中 db 时间戳为“2013-06-08 05:00:00.0”。

尽管使用 执行相同的查询时postgresAdminII,它会给出正确的 PVS.SCHED_DTE。

SELECT PVS.PTNT_VISIT_SCHED_NUM,   PVS.PTNT_ID,P.FIRST_NAM AS   PTNT_FIRST_NAM,P.PRIM_EMAIL_TXT,P.SCNDRY_EMAIL_TXT,   PVS.PTNT_NOTIFIED_FLG,PVS.SCHED_DTE,PVS.VISIT_TYPE_NUM,PVS.DURTN_TYPE_NUM,PVS.ROUTE_TYPE_NUM,   C.FIRST_NAM AS CARE_FIRST_NAM,C.MIDDLE_INIT_NAM AS   CARE_MIDDLE_NAM,C.LAST_NAM AS CARE_LAST_NAM,   C.PHONE_NUM_1,ORGNIZATN.EMAIL_HOST_SERVER_TXT,ORGNIZATN.PORT_NUM,   ORGNIZATN.MAIL_SENDER_USER_ID,ORGNIZATN.MAIL_SENDER_PSWD_DESC,ORGNIZATN.SOCKET_FCTRY_PORT_DESC,   ORGNIZATN.TIMEZONE_ID   FROM IHCAS.PTNT_VISIT_SCHED PVS ,   IHCAS.PTNT P,   IHCAS.ROUTE_LEG RL,   IHCAS.ROUTE R, IHCAS.CAREGIVER C,IHCAS.ORG   ORGNIZATN WHERE   ORGNIZATN.ORG_NUM = ? AND   PVS.SCHED_STAT_CDE = '2002' AND   PVS.PTNT_NOTIFIED_FLG =   FALSE      AND **PVS.SCHED_DTE >= (CURRENT_DATE + interval '1 day') AT TIME ZONE ? at TIME ZONE 'UTC'**   AND **PVS.SCHED_DTE < (CURRENT_DATE + interval '2 day' - interval '1 sec') AT TIME ZONE  ? at TIME ZONE 'UTC'**   AND PVS.PTNT_ID = P.PTNT_ID AND PVS.PTNT_VISIT_SCHED_NUM =   RL.PTNT_VISIT_SCHED_NUM   AND   RL.ROUTE_NUM = R.ROUTE_NUM AND   C.CAREGIVER_NUM=R.ASGN_TO_CAREGIVER_NUM   AND PVS.ORG_NUM=   ORGNIZATN.ORG_NUM   ORDER BY PVS.SCHED_DTE   ASC,PVS.ROUTE_TYPE_NUM   ASC,PVS.ORG_NUM ASC   
Parameters: **[1, EST, EST]**

Header: [PTNT_VISIT_SCHED_NUM, PTNT_NOTIFIED_FLG, **SCHED_DTE**, VISIT_TYPE_NUM, DURTN_TYPE_NUM, ROUTE_TYPE_NUM, PTNT_ID, PTNT_FIRST_NAM, PRIM_EMAIL_TXT, SCNDRY_EMAIL_TXT, CARE_FIRST_NAM, CARE_MIDDLE_NAM, CARE_LAST_NAM, PHONE_NUM_1, EMAIL_HOST_SERVER_TXT, PORT_NUM, MAIL_SENDER_USER_ID, MAIL_SENDER_PSWD_DESC, SOCKET_FCTRY_PORT_DESC, TIMEZONE_ID]
Result: [1129, false, **2013-06-07 23:30:00.0**, 1002, 1551, 1702, PID146, Ricky, Receiver.test@******.com, , Vikas, S, Jain, 956-**-5**8, 172.17.*.***, 25, Sender.test@******.com, ********123, 465, EST]

对我来说..这似乎是一些时区问题,但要解决什么以及如何解决。注意:本地时区:IST 应用程序时区:EST 在数据库中,列的数据类型是没有时区的时间戳。

任何建议.. ??

4

1 回答 1

0

最好将数据库时区设置为 UTC 并实现一个保留 UTC 的 MyBatis 类型处理程序,如已接受的答案所示: What's the right way to handle UTC date-times using Java, iBatis, and Oracle? .

于 2013-06-12T00:18:18.030 回答