开发者

hibernate JDBC type not found

Does hibernate have any mapping for this oracle data type:(10G) TIMESTAMP(6) WITH TIME ZONE

I am getting: No Dialect mapping for JDBC type: -101

My manager does not want to do the: registerHibernateType(-101, Hibernate.getText().getname())

H开发者_开发问答e thinks it is too much.:) What alternative can I have?


The answer you provide to yourself is more like a workaround than a proper solution. For the sake of the visitors looking for an answer, I'll provide my view on this:

1) Database date-based fields should be always set to UTC, never with a specific timezone. Date calculation with timezone information is an unneeded complexity. Remember that timezones usually changes twice a year for a lot of countries in the world ("daylight saving time"). There's a reason why only a few RDMBS' supports this, and there's a reason why Hibernate developers refuse to support this data-type. The patch for Hibernate is simple enough (one line of code), the implications aren't.

2) Converting your "timestamp with timezone" to a String will only cause problems later. Once you retrieve it as String, you'll need to convert it again to a Date/Calendar object, an unneeded overhead. Not to mention the risks associated with this operation.

3) If you need to know in which timezone is some user, just store the String representing the timezone offset (like "Europe/Prague"). You can use this in Java to build a Calendar with date/time and timezone, as it'll take care of DST for you.


For now, I solved the problem by:

`select TO_CHAR(TRUNC(field)) from table` //field is the one having type= timestamp with timezone

This ensures that when the query returns, the field has datatype 'String'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜