This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve timestamp value "-infinity" from PostgreSQL using JPA Hibernate

 
Iqbal Yusuf
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to fetch values stored in PostgreSQL 9.1. The field type is "timestamp with time zone". The value stored is "-infinity". When I use JPA / Hibernate annotation it provides me with a weird date value. My Entity Java class has declared the date as java.util.Date().

Here is the System.out when I print my Date from Java that JPA / Hibernate retrieves from PGSQL.

292269055-12-02 23:00:00.0

Here is a snippet of my Java Entity showing annotation for my date type.

@Column( name = "from_date")
private Date from_date;

I've read somewhere that PostgreSQL's JDBC driver can store and read timestamp values stored as "-infinity" and "infinity". If Hibernate / JPA doesn't support that is it possible to use custom converter to get these values?

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iqbal,
Welcome to CodeRanch!

I think that "weird value", you are getting is actually ok. This post on the postgresql mailing list, suggests there are constants you can compare the "infinity" dates to on a Date object.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic