-
1. Re: set of Attributes as member of an entytybean
sunfire May 8, 2006 11:11 AM (in response to micho)Since enum is a fixed set of attributes I don't think it would make much sens to save it into a DB. So why persist something that does not change at runtime and is part of your code?
Usualy you only want to save the value on an enum attribute inside of an Entity and this would look somthing like this@Entity public class Storage { public enum StorageType { STUFF, MORE_STUFF, OTHER_STUFF } @Enumerated(EnumType.STRING) private StorageType storageType; }
This would create a field of whatever String type is in your DB implementation and would store values like "STUFF" or "OTHER_STUFF" in it for the Entity.
Hope this helps -
2. Re: set of Attributes as member of an entytybean
micho May 8, 2006 11:43 AM (in response to micho)I want vo store any possibel set of attribut combinations.
@Entity
public class Storage {
public enum StorageType { STUFF, MORE_STUFF, OTHER_STUFF }
@Enumerated(EnumType.STRING)
private Set storageType;
void add (StorageType stuff)
{ storageType.add(stuff); }
}
..
public static void main(String[] args)
{
Storage storage = new Storage();
storage.add(StorageType.STUFF);
storage.add(StorageType.MORE_STUFF);
... -
3. Re: set of Attributes as member of an entytybean
cyril.joui May 8, 2006 12:21 PM (in response to micho)I am not sure you can do this ..
You may use another entity for StorageType and use ManyToMany ?
I think you can use enum fonctionnality.
Let's look at enum sets :
>
Enum sets also provide a rich, typesafe replacement for traditional bit flags:
EnumSet.of(Style.BOLD, Style.ITALIC)
<
see : http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html
Good luck !