-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Postgres and clobs
PostPosted: Fri Mar 26, 2004 3:57 pm 
Newbie

Joined: Mon Mar 01, 2004 11:50 am
Posts: 5
Hi,

I am using Hibernate 2.1.2 and Postgres 7.4.1 and jdbc driver pg74.1jdbc3.jar. I have a persistent object that holds a Clob. I have found that the schema generated for the underlying persistent table maps the clob type to a TEXT field for Postgres. I have found that inserts work properly, and the clob object is copied correctly into the text column. However, on retrieval it fails because ihibernate is expectinga clob ID in the column for the CLOB, rather than realizing that it is a text field and does not require a separate fetch of the Clob.

A BadInteger Exception gets raised when trying to retrieve the clob ID from the result set. The partial stack to the point where it dives into the postgres driver is:

AbstractJdbc2ResultSet.getClob() 325
ClobType.get() 32
NullableType.nullSafeGet() 62
NullableTYpe.nullSafeGet() 53
AbstractType.hydrate() 66
Loader.hydrate() 611
Loader.loadFromResultSet() 552
Loader.instanceNotYetLoaded() 511
Loader.getRow() 426
Loader.doQuery() 209
Loader.doQueryAndInitializeNonLazyCollections() 133
Loader.doList() 950
Loader.list() 941
QueryTranslator.list() 834
SessionImpl.find() 1512

A snippet of the java class is:

/**
* @hibernate.property
*/
public Clob getDocument() { return document; }
public void setDocument (Clob document) { this.document = document; }

The snippet of the mapping file is:
<property
name="document"
type="java.sql.Clob"
update="true"
insert="true"
column="document"
/>
and finally the schemaexport output is:
create table pedigree_doc (
id INT8 not null,
document TEXT,
conv_handle VARCHAR(255) unique,
unpacker_class VARCHAR(255),
origin INT2 not null,
handoff INT2 not null,
primary key (id)
);


I imagine that I can work around this, but this is clearly a bug. Having a non-symmetric implementation of clob for Postgres is unusable.

Thanks in advance
Craig


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 4:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
I imagine that I can work around this, but this is clearly a bug.


Um. Postgres does not support Clobs or Blobs. What's your point?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 5:01 pm 
Newbie

Joined: Mon Mar 01, 2004 11:50 am
Posts: 5
Yes, I recently became aware that Postgres doesn't support Clobs. I would have appreciated an early error message perhaps when generating the DDL for the Postgres dialect that clobs weren't available. I felt I was misled, however, because what happened instead was that hibernate tried to make up for the lack of Clob support by noticing that Postgres does offer Text fields for long character data.

I apparently was mistaken that mapping Clob to TEXT in the case of Postgres dialect was intentional.

Thx
Craig


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.