-->
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: Array of primitive type inside the same table of the entity
PostPosted: Wed May 02, 2007 8:13 am 
Newbie

Joined: Fri Oct 21, 2005 9:27 am
Posts: 13
Hi,

I'm using Hibernate 3.2 with annotations.
I'd like to persist an array of double (the primitive type) inside the same table as the whole class, just like a component would be.
I'd like to do that because my array has only just six elements, so I think it would be faster to fetch if it lies inside the same table as the class it belongs to, rather than a separate one.
Unfortunately I don't know if Hibernate can do that.

Here's my snippet of code representing what I'm trying to accomplish :

Code:
@Entity
@Table(name="RATES")
public class Rate {
   
    private Long id;
    //Other fields declarations
   
    private static final int VOLUME_COUNT = 6;
    private double[] rates = new double[VOLUME_COUNT];

    //Constructors and getters,setters with Hibernate annotations
    private double[] getRates() {...}

    //...
}


So, is it possible to persist an array the way I'd like to, or should I use another table to store it ?

Thanks in advance.


Top
 Profile  
 
 Post subject: Easy
PostPosted: Wed May 02, 2007 8:24 am 
Regular
Regular

Joined: Wed Aug 24, 2005 11:49 am
Posts: 63
It is fairly easy,
have a look at:
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#mapping-types-custom

_________________
Edwin van der Elst
Finalist IT Group


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 8:29 am 
Newbie

Joined: Fri Oct 21, 2005 9:27 am
Posts: 13
Thanks a lot. I didn't think about it but it is indeed obvious :)


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.