• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 36656
475
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.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!