pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Joseph Krogh <andreak@officenet.no>
To: pgsql-jdbc@postgresql.org
Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob
Date: Wed, 09 Feb 2011 09:04:05 +0100
Message-ID: <4D524A75.2090305@officenet.no> (raw)
In-Reply-To: <alpine.BSO.2.00.1102081917080.25347@leary.csoft.net>
References: <201102070001.22259.andreak@officenet.no>
	<201102070911.20245.rsmogura@softperience.eu>
	<4D505B02.804@officenet.no>
	<alpine.BSO.2.00.1102081917080.25347@leary.csoft.net>

On 02/09/2011 01:20 AM, Kris Jurka wrote:
> 
> 
> On Mon, 7 Feb 2011, Andreas Joseph Krogh wrote:
> 
>> It's not clear to me why the JDBC-driver for PG shouldn't just use
>> rs.getString() internally for getClob() calls? Requiring
>> special-handling in Hibernate for dealing with Strings by setting an
>> obscure property just doesn't seem right. And I don't want to set a
>> property to handle CLOB which might affect how I use BLOBs.
>>
> 
> The problem is that we have no idea what someone might want to do with a
> CLOB after they've fetched it.  You're coming from the idea that all
> they want to do is read it and copy the data out to a String.  From that
> perspective it's not hard to have a Clob wrapper around a String, but
> what happens when they say clob.setString(13, "data")?  Are we going to
> try and figure out what row of what table that varchar column is coming
> from and do a partial update on it?

The javadoc for clob.setString(index, data) says:
----------------------------------------
Writes the given Java String to the CLOB value that this Clob object
designates at the position pos. The string will overwrite the existing
characters in the Clob object starting at the position pos. If the end
of the Clob value is reached while writing the given string, then the
length of the Clob value will be increased to accomodate the extra
characters.

Note: If the value specified for pos is greater then the length+1 of the
CLOB value then the behavior is undefined. Some JDBC drivers may throw a
SQLException while other drivers may support this operation.

Parameters:
pos - the position at which to start writing to the CLOB value that this
Clob object represents; The first position is 1
str - the string to be written to the CLOB value that this Clob designates
----------------------------------------

So, I think clob.setString(index, data) should behave just like
StringBuilder.insert(int offset, String str) except overwrite existing
data instead of moving the characters above the position.

-- 
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / CTO
Public key: http://home.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Rosenholmveien 25       | know how to do a thing and to watch         |
1414 TrollÄsen          | somebody else doing it wrong, without       |
NORWAY                  | comment.                                    |
Org.nr: NO 981 479 076  |                                             |
                        |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+



view thread (36+ messages)  latest in thread

Message-ID: <4D524A75.2090305@officenet.no>
Permalink:  ../4D524A75.2090305@officenet.no/
Also on:    postgresql.org/message-id/4D524A75.2090305@officenet.no

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: andreak@officenet.no
  Subject: Re: ResultSet.getClob() causing problems when used with JPA's @Lob
  In-Reply-To: <4D524A75.2090305@officenet.no>
  References: <201102070001.22259.andreak@officenet.no> <201102070911.20245.rsmogura@softperience.eu> <4D505B02.804@officenet.no> <alpine.BSO.2.00.1102081917080.25347@leary.csoft.net> <4D524A75.2090305@officenet.no>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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