Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

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?

author & internet detective
Posts: 40035
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic