pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
TimestampUtils.loadCalendar failes for interval type
3+ messages / 3 participants
[nested] [flat]

* TimestampUtils.loadCalendar failes for interval type
@ 2005-09-08 11:26 Gil G <gm12345678@gmail.com>
  2005-09-11 23:11 ` Re: TimestampUtils.loadCalendar failes for interval type Dave Cramer <pg@fastcrypt.com>
  2005-09-11 23:13 ` Re: TimestampUtils.loadCalendar failes for interval type Oliver Jowett <oliver@opencloud.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Gil G @ 2005-09-08 11:26 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

I've executed following query: 
select t.date-t.date2 from table as t

The query should return a single row of type interval. Indeed, 
resultSet.getObject(1) returns a PGInterval instance with the correct value 
(the returned interval is 2 days and several hours).

When I call resultSet.getString(1) the string representation of interval is 
"2 days 14:08:55.8246".
The problem arises when I call resultSet.getTimestamp(1). 
As I saw in org.postgresql.jdbc2.TimestampUtils.loadCalendar(GregorianCalendar 
cal, String s, String type) it fails to parse correctly 
the string, which is returned by resultSet.getString(1) call. since it 
expects only the "14:08:55.8246" part and does not expect the "2 days " part. 
Please note that in case the interval between two dates is smaller than 24 
hours everything works correctly. 

This is important since, generic products such as Hibernate that work over 
different jdbc drivers, refer to the interval data type as a 
java.sql.Timestamp object and call getTimestamp(int) method on the resultset 
to get the instance.

Thanks,
Gil

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: TimestampUtils.loadCalendar failes for interval type
  2005-09-08 11:26 TimestampUtils.loadCalendar failes for interval type Gil G <gm12345678@gmail.com>
@ 2005-09-11 23:11 ` Dave Cramer <pg@fastcrypt.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Dave Cramer @ 2005-09-11 23:11 UTC (permalink / raw)
  To: Gil G <gm12345678@gmail.com>; +Cc: pgsql-jdbc

I would suggest you send a bug note to Hibernate. An inteval is not a  
timestamp, nor can it be construed as such.

Dave
On 8-Sep-05, at 7:26 AM, Gil G wrote:

> Hi,
>
> I've executed following query:
> select t.date-t.date2 from table as t
>
> The query should return a single row of type interval. Indeed,  
> resultSet.getObject(1) returns a PGInterval instance with the  
> correct value (the returned interval is 2 days and several hours).
>
> When I call resultSet.getString(1) the string representation of  
> interval is "2 days 14:08:55.8246".
> The problem arises when I call resultSet.getTimestamp(1).
> As I saw in org.postgresql.jdbc2.TimestampUtils.loadCalendar 
> (GregorianCalendar cal, String s, String type) it fails to parse  
> correctly
> the string, which is returned by resultSet.getString(1) call. since  
> it expects only the "14:08:55.8246" part and does not expect the "2  
> days " part. Please note  that  in case the interval between two  
> dates is smaller than 24 hours everything works correctly.
>
> This is important since, generic products such as Hibernate that  
> work over different jdbc drivers, refer to the interval data type  
> as a java.sql.Timestamp object and call getTimestamp(int) method   
> on the resultset to get the instance.
>
> Thanks,
> Gil

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: TimestampUtils.loadCalendar failes for interval type
  2005-09-08 11:26 TimestampUtils.loadCalendar failes for interval type Gil G <gm12345678@gmail.com>
@ 2005-09-11 23:13 ` Oliver Jowett <oliver@opencloud.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Oliver Jowett @ 2005-09-11 23:13 UTC (permalink / raw)
  To: Gil G <gm12345678@gmail.com>; +Cc: pgsql-jdbc

Gil G wrote:

> This is important since, generic products such as Hibernate that work
> over different jdbc drivers, refer to the interval data type as a
> java.sql.Timestamp object and call getTimestamp(int) method  on the
> resultset to get the instance.

AFAIK there's no standard mapping for 'interval' in JDBC so I don't
think you should be too suprised that trying to represent it as a
Timestamp fails.

However your email implies that there are other JDBC drivers that do
represent an interval as a Timestamp. Can you provide some examples of
drivers that do this, and details of how code such as Hibernate is
expecting the interval to be represented? Maybe we can do an appropriate
conversion as a nonstandard extension.

-O



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-09-11 23:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08 11:26 TimestampUtils.loadCalendar failes for interval type Gil G <gm12345678@gmail.com>
2005-09-11 23:11 ` Dave Cramer <pg@fastcrypt.com>
2005-09-11 23:13 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox