-->
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: PSQLException while reading a blob
PostPosted: Mon May 17, 2004 10:35 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hello,

I got the problem that I'm not able to load a previous stored record from the DB (Postgres 7.4.2 in my case).
Storing the blob works fine, but if I try to load everything screws up. I get a illegal format of Integer while loading the blob.

Here's the code snipplet and the mapping:

Hibernate Version: 2.1.3

Mapping:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="Attachment"
table="attachment"
schema="public"
proxy="Attachment"
>

<id
name="attachmentId"
type="java.lang.Integer"
column="attachment_id"
>
<generator class="sequence">
<param name="sequence">attachment_attachment_id_seq</param>
</generator>
</id>

<property
name="description"
type="java.lang.String"
column="description"
not-null="true"
length="255"
/>
<property
name="data"
type="java.sql.Blob"
column="data"
not-null="true"
length="255"
/>

<!-- associations -->
<!-- bi-directional many-to-one association to Comment -->
<many-to-one
name="comment"
class="Comment"
not-null="true"
>
<column name="comment_id" />
</many-to-one>

</class>
</hibernate-mapping>

Code between opening and closing the session:
List ret = sess.find("from Attachment as attachment where attachment.comment.commentId = " + commentId);

Stacktrace:

15:23:39,046 INFO [STDOUT] Hibernate: select attachment0_.attachment_id as attachme1_, attachment0_.description as descript2_, attachment0_.data as data, attachment0_.comment_id as comment_id from public.attachment attachment0_ where (attachment0_.comment_id=31 )
15:23:39,125 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 22003
15:23:39,125 ERROR [JDBCExceptionReporter] Ung


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 12:47 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Probably it is caused by wrong field type , do you use "BETEA" or "OID" ?
It looks like driver wants "pointer" not an array for Blob.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 3:45 pm 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Changing the Type from Blob to binary was the clue.
Thx for the suggestion.

best regards

Olaf


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.