-->
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: storing a byte array in postgres
PostPosted: Tue Jul 10, 2007 8:37 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 10:51 pm
Posts: 29
Location: sydney australia
Hibernate 3.2.2
Postgres 8.2

I'm trying to store a GZIP byte array in my database. My field is a byte[], and my column type is text of unspecified length. with this combination i get the error:
column "myColumn" is of type text but expression is of type bytea

I tried using field type String and converting the byte[] to String using new String(byte[], Charset.forName("UTF8")) (which worked) but when inserting via hibernate I was getting this error:
ERROR: invalid byte sequence for encoding "UTF8": 0x00

So is there a better data type to use rather than text or is there a way of encoding the byte[] to String so it doesn't cause problems?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 9:19 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 10:51 pm
Posts: 29
Location: sydney australia
going with text data type and Base64 encoding.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 9:19 am 
Newbie

Joined: Thu Jun 15, 2006 8:32 am
Posts: 6
I use hibernate-annotations

For storing a file I use byte[]:

@Column(name="xsltToDC")
private byte[] xsltToDC;

And Hibernate creates a field with type: bytea (on PostgreSQL 8.2.4)

Hope this helps


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.