-->
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: Collection of primitives on OneToMany relationship
PostPosted: Thu Nov 22, 2007 5:39 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:11 am
Posts: 22
Is it possible to have OneToMany relation, but have collection of primitive's instead of collection of entities?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 10:58 pm 
Newbie

Joined: Fri Mar 30, 2007 5:23 pm
Posts: 16
Location: New York, NY
Hibernate doesn't play nice with primitives, but you can certainly use built-in classes that wrap primitives (e.g. Integer, Character, etc.) or any other scalar type that has an analog in your database:

http://www.hibernate.org/hib_docs/v3/re ... s-ofvalues


Top
 Profile  
 
 Post subject: Re: Collection of primitives on OneToMany relationship
PostPosted: Fri Nov 23, 2007 6:03 am 
Newbie

Joined: Fri Oct 12, 2007 5:51 pm
Posts: 5
Example using annotations (you need to change some names to fit your need)

@CollectionOfElements
@JoinTable(name = "somename_othername",
joinColumns = @JoinColumn(name = "some_id"))
@Column(name = "some_column", length = MAX_SOME_LENGTH)
@Immutable
private Set<String> someCollection;


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.