Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A0D386328F5 for ; Sat, 10 Apr 2010 08:37:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 21414-02 for ; Sat, 10 Apr 2010 11:36:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id D31B763287B for ; Sat, 10 Apr 2010 08:36:50 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 8646BAF045; Sat, 10 Apr 2010 19:34:38 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail2.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id o0SxdUsnUJLf; Sat, 10 Apr 2010 19:34:33 +0800 (WST) Received: from [10.1.1.5] (203-206-36-38.dyn.iinet.net.au [203.206.36.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 626E2AF0B8; Sat, 10 Apr 2010 19:34:33 +0800 (WST) Message-ID: <4BC062CA.9050104@postnewspapers.com.au> Date: Sat, 10 Apr 2010 19:36:42 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Rafael Felix CC: pgsql-jdbc@postgresql.org Subject: Re: Migration to Hibernate 3.5 final References: <4BBF3B9A.9070607@serhmatica.com.br> In-Reply-To: <4BBF3B9A.9070607@serhmatica.com.br> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.698 tagged_above=-10 required=5 tests=AWL=-0.698 X-Spam-Level: X-Archive-Number: 201004/14 X-Sequence-Number: 20425 Rafael Felix wrote: > I´ve an application running in hibernate 3.3.2 and the applications > 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 are 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. Consider using vacuumlo . -- Craig Ringer