wood burning stoves 2.0*
The moose likes Other Application Frameworks and the fly likes Hibernate mapping collection of primitives Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Hibernate mapping collection of primitives" Watch "Hibernate mapping collection of primitives" New topic
Author

Hibernate mapping collection of primitives

Victor Balanica
Greenhorn

Joined: Jan 11, 2011
Posts: 5

Does anyone have a working example on Hibernate's mapping a collection of primitives with annotations ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

From the Hibernate Documentation


2.2.5.3.3. Collection of basic types or embeddable objects

In some simple situation, do don't need to associate two entities but simply create a collection of basic types or embeddable objects. Use the @ElementCollection in this case.

@Entity
public class User {
[...]
public String getLastname() { ...}

@ElementCollection
@CollectionTable(name="Nicknames", joinColumns=@JoinColumn(name="user_id"))
@Column(name="nickname")
public Set<String> getNicknames() { ... }
}



Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Victor Balanica
Greenhorn

Joined: Jan 11, 2011
Posts: 5

Thanks, it has been very helpfull
 
 
subject: Hibernate mapping collection of primitives
 
Similar Threads
Collections
wrapper class
garbage collection
doubt about strings creation
are wrapper classes intialized to zero?