本文介绍了如何使用Hibernate 3.3.2GA将TIMESTAMP WITH TIME ZONE映射到Java数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何映射Oracle列类型或转换为Java数据类型,使用 3.3.2GA?我可以将其中的每一个映射到或数据类型?

How can I map Oracle column types TIMESTAMP WITH TIME ZONE or TIMESTAMP WITH LOCAL TIME ZONE to a Java data type using Hibernate 3.3.2GA? Can I map each of these to a Date or Calendar data type?

推荐答案

href =http://joda-time.sourceforge.net/ =nofollow> joda-time 。它有一个

Use joda-time. It has an extension for hibernate

@Columns(columns={@Column(name="startTime"),@Column(name="startTimezone")})
@Type(type="org.joda.time.contrib.hibernate.PersistentDateTimeTZ")
private DateTime startDateTime;

但首先确保您确实需要存储时区。更好的做法是将时间存储在固定的TZ(例如UTC)中,并根据当前用户首选项显示它们。人们对 时区中的事件感兴趣,而不是事件源的时区。

But first make sure you really need to store the time-zone. A better practice is to store times in a fixed TZ (say, UTC), and display them according to the current user preferences. People are interested in the time of an event in their timezone, and not in the timezone of the event source.

这篇关于如何使用Hibernate 3.3.2GA将TIMESTAMP WITH TIME ZONE映射到Java数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 22:45