[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[eclipselink-users] Advice request for storing a List of Enum values
|
- From: "Martijn Morriën" <dj.escay@xxxxxxxxx>
- Date: Mon, 1 Dec 2008 11:36:48 +0100
- Delivered-to: eclipselink-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=9vwWZI02GKS70BmdvQQXIoG2J/sy09VTaH7YMhrWBiI=; b=xX90NZUSNYNLZWdUJyq3kpVehETfzjxPyV+lkha6tnUZrO0Cawn6v9pSH8PgnmSPP+ v/IkZJfX23L3Wbf4uVyJEAg4en8CGrNRuES48OFounH78m3lU7XvE6DOE/BSa5TbjZRp d/Yr1gKlzwA/t9x32bavX7fQs3cW/q7j9Aeo0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=p5MTm8vdHMwooNKyD/hqEX/AedbcxSkWWOVPZW4PLISsdsIBsWgIm0AWE/BtrPgEz6 SklhpIOS/C4YFqKJrYfHA+vZ5Aoxq0igv/vEGI7rFiT2XkcLbHq3/5ppooFq3hBbRMGN HRGy0SRdfz/F5E48IyjkvximVJVITcKc0Iwng=
Hi, I am looking for implementation tips for storing a List of Enum values.
I have been reading the
http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg00915.html
thread, it gives me some options but I'm not sure what path to take. I
will try to explain my model first and then I list a number of
concerns I have.
I want to have a model like:
User --* Role *-- Action
public class User {
private List<Role > roles;
public List<Role > getRoles() {
return roles;
}
public void setRoles(List<Role > value) {
this.roles= value;
}
}
public class Action {
private List<Role > roles;
public List<Role > getRoles() {
return roles;
}
public void setRoles(List<Role > value) {
this.roles= value;
}
}
public enum Role {
admin,
user
}
I want the database to look like:
Table User
- Column id
Table Action
- Column id
Table User_Role
- Column userId
- Column roleId
Table Action_Role
- Column actionId
- Column roleId
Table Role
- Column id (Enum string value, primary key)
- The Role table will be manually filled with 2 rows: 'admin' and
'user' when the database is created.
- The User_Role and Action_Role will have foreign key constrains to
the relevant tables.
- With this approach I ensure database integrity.
Should I use a BasicCollection (like the advice given here:
http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg00917.html)
the way to go? If so, is there somewhere an example which uses Enums?
Or do I need to fall back on a Class mapping, which is portable to
other JPA implementations, but requires me to convert class values to
java enums?
Thank you,
Martijn