-->
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.  [ 6 posts ] 
Author Message
 Post subject: Understanding array serialization
PostPosted: Fri Jun 29, 2007 10:34 am 
Newbie

Joined: Fri Jun 29, 2007 10:12 am
Posts: 3
I use Hibernate to persist some of my Java classes to a database. Often I will write scripts in other programs (such as Python) to do some analysis on the persisted data. However, some of these classes have arrays of primitive types (such as Integer[][]) which appear to be persisted as a byte stream to the database. I'd like to figure out how to interpret this byte stream using another language, but am having difficulty finding information on the internet. I am not sure whether this is a Hibernate-specific issue or a Java issue and was hoping someone could point me in the right direction.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:02 am 
Newbie

Joined: Tue Jun 26, 2007 3:24 pm
Posts: 11
Could you post your mapping file so we can see exactly how you are persisting it? By the way, Integer is a class which wraps the primitive type int.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:07 am 
Newbie

Joined: Fri Jun 29, 2007 10:12 am
Posts: 3
I'm using Hibernate Annotations, so the entity is marked as followed:

@Entity
public class Waveform implements Serializable {

@Id
private Long id;

Double[][] rawWaveform;
Double stimulusDuration;
Integer stimulusLevel;

<-- constructor and methods go here -->

Is this the information that you needed? I can provide the entire class file if necessary.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:20 am 
Newbie

Joined: Tue Jun 26, 2007 3:24 pm
Posts: 11
I'm not familiar with hibernate annotations, but I'm sure someone else will be able to help.


Top
 Profile  
 
 Post subject: Array serialization
PostPosted: Wed May 28, 2008 1:10 pm 
Newbie

Joined: Wed May 28, 2008 11:11 am
Posts: 12
So you are mapping a member variable of type Double[][] to some column in the database, using annotations? Does it work? How do you do that?

I am interested in knowing how to map a variable of type double[] to a database column of the same type (PostgreSQL). Any ideas?

Thanks, venkman


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 9:40 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Quote:
Of course, if you've worked with any of the big databases, you're probably familiar with Blobs and Clobs. There is no Blob or Clob annotation to speak of in Hibernate; instead, when Hibernate sees the @Lob annotation, it inspects the Java datatype. If the Java datatype that is decorated with the @Lob annotation is a String, java.sql.Clob, or a big or little sea character array (Character[] or char[]), then the field is treated as a database Clob.

On the other hand, if the Java datatype is a java.sql.Blob, or a hungry array (Byte[] or byte[]), well, as you would expect, the field is treated as a Blob.


http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=06hibernatetableandcolumnmappingwithjpa

Well, Hiberante put that blob in there. If you use Hibernate to pull it out, you won't have any problems.

What does the data stream actually look like in the database? Is it totally indecipherable? My guess is that it is, in which case, it'd probably take a pretty smart query to pull it out and put it back into a workable format that you could effectively manipulate in a Java/J2EE application.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.