-->
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.  [ 2 posts ] 
Author Message
 Post subject: Annotation to flatten an array
PostPosted: Wed Jul 18, 2012 11:12 am 
Beginner
Beginner

Joined: Fri Jul 20, 2007 10:38 am
Posts: 49
Hello,

I'm using Hibernate 3.6.9-FINAL with annotations. I'm working on a legacy database that I can't modify. I'm looking for a way of doing the following with annotations.
I have to execute the basic crud operations on a table with three columns: id, name and account. The account has a primary key constraint on it. I was hoping I could create a pojo that just has the three fields where the account is an array and when I saveOrUpdate Hibernate will look at it as individual items:

Code:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Integer id;

@Column(name = "name")
private String name;

@Column(name = "account")
private String[] account;


If I saveOrUpdate this, the account-array is serialized as one object, is there an annotation that allows me to define a one-to-many or something in the same table? Perhaps I have to reverse the whole thing, look at it from the account.

thanks for any thoughts,
Lino


Top
 Profile  
 
 Post subject: Re: Annotation to flatten an array
PostPosted: Wed Jul 18, 2012 11:28 am 
Beginner
Beginner

Joined: Fri Jul 20, 2007 10:38 am
Posts: 49
I was looking at the @ElementCollection annotation here: http://en.wikibooks.org/wiki/Java_Persi ... Collection but that still uses a 1-to-n relation...


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