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: Mapping List of enums in JPA
PostPosted: Thu Apr 08, 2010 4:00 pm 
Newbie

Joined: Thu Apr 08, 2010 3:47 pm
Posts: 1
I have entity Person:

@Entity
@Table(schema="", name="PERSON")
public class Person {
List<PaymentType> paymentTypesList;

//some other fields

//getters and setters and other logic
}

and I have enum PaymentType:

public enum PaymentType {
FIXED, CO_FINANCED, DETERMINED;
}

how to persist Person and its list of enums (in this list i have to place variable amount of enums, there may be one of them, or two or all of them)

I'm using Spring with Postgres, Entity are created using JPA annotation, and managed using Hibernate


Top
 Profile  
 
 Post subject: Re: Mapping List of enums in JPA
PostPosted: Fri Apr 09, 2010 4:29 am 
Regular
Regular

Joined: Thu May 07, 2009 5:56 am
Posts: 94
Location: Toulouse, France
JPA 1.0 doesn't support collection of basic types...you can wrap the Enum into an entity class and wrap/unwrap enum in set/get methods...(I know it isn't a proper solution but JPA 1.0 is minimal)
if you use JPA 2.0 take a look at @ElementCollection (http://en.wikibooks.org/wiki/Java_Persi ... Collection)

_________________
everything should be made as simple as possible, but not simpler (AE)


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.