-->
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.  [ 4 posts ] 
Author Message
 Post subject: Need to save a List to a column
PostPosted: Fri Dec 15, 2006 6:41 am 
Newbie

Joined: Fri Dec 15, 2006 6:33 am
Posts: 2
Hi

I am using mysql 4.1 and I have a class as folllows:-
@Entity
@Table(name = "PortedNumberRelayTasks")
public class PortedNumberRelayTask implements Serializable {
......



}

The relevent section is
@Column(name="portednumberList")
@Type(type="text")
private List portednumberlist;

Basically I wanted to store a List into the database and then be able to get at the list when it was required. Mysql does not have an array type per se and so I am not sure how I should go about this? Currently I created my column as a text field, but have tried blob as well. I am also not sure if its possible to do such a thing

I have another Entity called PortedNumber and this List is a List of PortedNumbers.

Do I have to have another table and store the id link to it such as
table PortedNumberRelayTask
has a field called ListId int

and then have some other table PortedNumberList
Listid
blob the PortedNumber
eg
1, PortedNumber1
1,PortedNumber2
1,PortedNumber3 etc?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 15, 2006 8:44 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

You need to create a relationship between the entities, or alternatively you could use the @CollectionOfElements annotation. Seems as the list you want to persist is a list of entities, i would recommend that you take the relationship approach to store the list.

Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 17, 2006 6:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
if you really want to store it in a single column (or a proprietary format), you can create a custom UserType

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 18, 2006 9:32 am 
Newbie

Joined: Thu Nov 09, 2006 5:32 am
Posts: 8
emmanuel wrote:
if you really want to store it in a single column (or a proprietary format), you can create a custom UserType


or if your list (and it's elements) are serializable you can store it in it's serialized form in one column without creating an UserType. Annotate it with @Type(type="serializable").

Octav


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.