-->
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.  [ 5 posts ] 
Author Message
 Post subject: How does Hibernate store an [] of objects ?
PostPosted: Tue Mar 17, 2009 3:43 am 
Newbie

Joined: Tue Mar 17, 2009 3:39 am
Posts: 3
Hi there !

I'm storing an array of objects in a table column, using Hibernate.
An array of entities to be exact.

Does anyone know, how these objects would be represented in the table column ? E.g. how would a long[] be stored in the DB ?

I need to use a SQL insert statement to insert the ARRAY values.

Thanks
- Michael


Top
 Profile  
 
 Post subject: Re: How does Hibernate store an [] of objects ?
PostPosted: Tue Mar 17, 2009 4:20 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
mkmichem wrote:
Hi there !

I'm storing an array of objects in a table column, using Hibernate.
An array of entities to be exact.

Does anyone know, how these objects would be represented in the table column ? E.g. how would a long[] be stored in the DB ?

I need to use a SQL insert statement to insert the ARRAY values.

Thanks
- Michael


It will be saved as blob


rate it if you are satisfied


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 5:05 am 
Newbie

Joined: Tue Mar 17, 2009 3:39 am
Posts: 3
Thanks for the quick reply !

I found this package from Oracle: utl_raw
One can use it to insert RAW blob data to the DB.

It doesn't seem to help with inserting arrays though.
Either way, i'm still not sure if my entities would be stored as long[].

mm .. maybe i should just create a many-to-many mapping after all :(.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 8:19 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
what is the relation between long[] and many-to-many? Can you explain your case?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 9:12 am 
Newbie

Joined: Tue Mar 17, 2009 3:39 am
Posts: 3
Yes sure ...

I have an array of long values.
Each long value refers to an entry in a Lookup Table.

So Eg.

public class SubjectCertificateAudit extends BaseEntity {

public long[] errorCodeIDs;

// getter and setters

}


, where every errorCodeID is a long value refering
to an entry in a lookup table.

Instead of saving the ID's as an array,
I could instead create a many-to-many mapping.

First wrap the ID as an entity:

public class ErrorCode extends BaseEntity {

}


, and then create the many-to-many association:

public class class SubjectCertificateAudit extends BaseEntity {

public List<ErrorCode> errorCodeIDs;

// getter and setters

}


This would ultimately create a join table, which would be
easier to populate using SQL insert statements.

Mm .. would have been nice to know how hibernate
would store an array of long values though.

I know it gets stored as a BLOB, but how does Hibernate identify
each array element inside of that BLOB.

Maybe it gets stored as comma delimited values,
or maybe all the elements in the array are just appended
(so every 4'th byte would be the start of a new element in a long[])... ?

I've browsed through all the reference DOC's I have on Hibernate,
none clarifying how Hibernate would store RAW BLOB data.

I would think that all the array elements would just be appended
to form one large BLOB. But that's just a guess ...


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