setBlob() copies the blob, even it was already a PostgreSQL blob!

Поиск
Список
Период
Сортировка
От Dobes
Тема setBlob() copies the blob, even it was already a PostgreSQL blob!
Дата
Msg-id e112f747-7bf4-410d-8efb-fbf90e508875@v12g2000prb.googlegroups.com
обсуждение исходный текст
Ответы Re: setBlob() copies the blob, even it was already a PostgreSQL blob!  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
Hi there,

Looking at org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(int,
Blob) it seems to copy the given blob, even if the blob was already a
PostgreSQL blob.

Ideally it would use the blob if it was already a PostgreSQL blob.

Why?  If you're using Blob object with Hibernate it can be useful to
create the blob in a new entity and write some stuff to it before
saving to the DB along with the entity.  Also, I suspect (but have not
yet confirmed) that hibernate will store the blob fields any time an
object is updated to the database along with the other fields (i.e. it
doesn't necessarily UPDATE only the changed fields, it may issue an
UPDATE that includes the blob's OID and uses the setBlob() method to
set it).

The way things are now took me quite by surprise and we can have a lot
of duplicate copies of the data in the database, poor performance,
etc..  It seems like an easy fix to check whether the blob passed in
is already a PostgreSQL blob and if so, re-use the same oid already
allocated.

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Kevin Grittner"
Дата:
Сообщение: Re: Using java.lang.Character for "char" data type
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: no timeout in AbstractJdbc23PoolingDataSource#getPooledConnection