Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id E21DC6358F1 for ; Mon, 12 Apr 2010 13:29:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 06101-09-2 for ; Mon, 12 Apr 2010 16:28:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from progressive.micfo.com (progressive.micfo.com [174.34.188.2]) by mail.postgresql.org (Postfix) with ESMTP id 2113263582D for ; Mon, 12 Apr 2010 13:28:37 -0300 (ADT) Received: from 87-204-194-135.dg-net.pl ([87.204.194.135]:55010 helo=radek.localnet) by progressive.micfo.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1O1MUy-0001lI-P6 for pgsql-jdbc@postgresql.org; Mon, 12 Apr 2010 11:28:33 -0500 From: =?utf-8?q?Rados=C5=82aw_Smogura?= To: pgsql-jdbc@postgresql.org Subject: Re: Migration to Hibernate 3.5 final Date: Mon, 12 Apr 2010 18:28:52 +0200 User-Agent: KMail/1.12.4 (Linux/2.6.31-gentoo-r10; KDE/4.3.5; x86_64; ; ) References: <201004101458.54501.rsmogura@softperience.eu> <4BC307ED.7070801@serhmatica.com.br> In-Reply-To: <4BC307ED.7070801@serhmatica.com.br> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201004121828.52833.rsmogura@softperience.eu> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - progressive.micfo.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - softperience.eu X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201004/19 X-Sequence-Number: 20430 Hi, I shuold give few words of explanation, which I didn't wrote because of=20 tragedy that was on 10th Apr in Smolensk. This generaly isn't bug in PG JDBC, but change of default implementation of= =20 Hibernate in 3.5 version (it should not happen, because some old legacy=20 application, without support or source code can't be migrated to Hibernate = 3.5=20 and so to J2EE6). In my situation setting compatible property on connection= =20 didn't helped.=20 Much more this what I saw in 3.5 - beta 2, and i don't know if this was fix= ed=20 is Hibernate - without @Type annotation - will auto-create column of type o= id=20 (correct!) , but will try to read this as bytea (SIC!) Dnia poniedzia=C5=82ek 12 kwiecie=C5=84 2010 o 13:45:49 Rafael Felix napisa= =C5=82(a): > Radoslaw and Craig, >=20 > Thanks for ansewers, the @Type annotations was worked for me. >=20 > About the Craig questions, I'm using the literal oid field. >=20 > Thanks for all >=20 > regards >=20 > Em 10/4/2010 09:58, Rados=C5=82aw Smogura escreveu: > > I had similar problems, try use on byte[] field following Hibernate > > annotation @Type(type=3D"org.hibernate.type.PrimitiveByteArrayBlobType") > > > > Dnia sobota 10 kwiecie=C5=84 2010 o 13:36:42 Craig Ringer napisa=C5=82(= a): > >> Rafael Felix wrote: > >>> I=C2=B4ve an application running in hibernate 3.3.2 and the applicati= ons > >>> works fine, with all blob fields using oid (byte[] in java), > >> > >> Do you mean you're using the literal type `oid' in the Pg fields? Or a= re > >> you using the `lo' contrib type? > >> > >> By using the `oid' type you're using out-of-line large objects, > >> referenced by object id (oid). > >> > >> If you use `oid' directly, then when you delete a row from your table > >> the corresponding large object will NOT be deleted. The `lo' wrapper > >> contrib type provides that. It's not in mainline yet (alas), perhaps > >> because it can't guarantee correctness - in particular a TRUNCATE TABLE > >> will still leak large objects. > >> > >>> Migrating to hibernate 3.5 all blob fields not work anymore, and the > >>> server log shows > >>> > >>> ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: column > >>> "preferencia" is of type oid but expression is of type bytea > >> > >> OK, so you're now mapping byte[] to the Pg type 'bytea' instead of to = pg > >> large objects. > >> > >> You can change this mapping in your hibernate settings if you want > >> things to go back to how they were. See large object mapping in the > >> Hibernate documentation. > >> > >>> But I'm cann't change the tables struct for use bytea instead oid, > >>> because I lost all data. > >> > >> Do you mean "because you've lost all your data" or "because by doing so > >> you will lose all your data"? > >> > >> I presume the latter. > >> > >> What I'd do would be: > >> > >> a) Change hibernate's mapping for byte[] back to large object instead = of > >> bytea by overriding it in the Hibernate configuration > >> > >> b) Evaluate whether bytea or large object is actually better for you by > >> reading the postgresql documentation and thinking a about your needs. > >> Consider how often you update the data, how big the maximum size of > >> object you need to store is, etc. > >> > >> c) Decide whether you should migrate to bytea or stick with large > >> objects. > >> > >> d) If you stick to large objects, switch from raw oid types to `lo' > >> types, so you get proper large object cleanup on delete/update. Consid= er > >> using vacuumlo . > >> > >> -- > >> Craig Ringer >=20