jpa oracle datetime,jpa – EclipseLink和Oracle DB的TimeZone错误

我正在编写一个使用JPA与GlassFish 3.1.2.2和EclipseLink 2.3.2的应用程序.我正在使用Oracle DB 11g并尝试使用TIMESTAMPTZ字段类型存储时区的日期和时间.

通过我的设置,我可以将时区的日期和时间保存到数据库中. (更新 – 实际上,当查看实际的SQL调用时,它只传递日期和时间.Oracle必须在保存到数据库时附加时区).

但是,当检索数据时,我收到以下异常:

Exception [EclipseLink-3002] (Eclipse Persistence Services – 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ConversionException

Exception Description: The object [oracle.sql.TIMESTAMPTZ@12cbe3f], of class [class oracle.sql.TIMESTAMPTZ], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[startDateTime–>APPT_EVENT.START_DATE_TIME]] with descriptor [RelationalDescriptor(com.ntst.caremanager.server.entities.ApptEvent –> [DatabaseTable(APPT_EVENT)])], could not be converted to [class java.util.Date].

以前有没有遇到过这个?这就是我的实体类中的’startDateTime’字段的设置方式:

@Column(name = "START_DATE_TIME")

@Temporal(TemporalType.TIMESTAMP)

private Date startDateTime;

START_DATE_TIME在DB中使用以下DDL定义:

"START_DATE_TIME" TIMESTAMP (6) WITH TIME ZONE

我已阅读eclipselink wiki here,EclipseLink本身支持oracle的TIMESTAMPTZ,无需任何转换.我也尝试在我的实体类中使用’Calendar’类型而不是’Date’时间.

更新:

也尝试了这个

@Convert("timestamptz")

@TypeConverter(name="timestamptz", dataType=TIMESTAMPTZ.class)

@Column(name = "START_DATE_TIME")

@Temporal(TemporalType.TIMESTAMP)

private Date startDateTime;

还没有运气.奇怪的是,随着转换器的添加,持久到数据库不再有效.尝试保存值时出现此错误.

Exception [EclipseLink-3002] (Eclipse Persistence Services – 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.ConversionException

Exception Description: The object [12/4/12 7:00 AM], of class [class java.util.Date], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[startDateTime–>APPT_EVENT.START_DATE_TIME]] with descriptor [RelationalDescriptor(com.ntst.caremanager.server.entities.ApptEvent –> [DatabaseTable(APPT_EVENT)])], could not be converted to [class oracle.sql.TIMESTAMPTZ].

尝试检索值时,我仍然遇到同样的错误.

我也尝试将Glassfish更新到EclipseLink 2.3.3并得到了同样的错误.

这是我的持久性文件:

org.eclipse.persistence.jpa.PersistenceProvider

CMDEV

false

有没有人见过这个问题,或者看到我可能犯的任何错误?

谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值