Hi there,

I'm currently developing an EJB3 project. I know the basics, so I can resolved "standard" problems on my own, but here I'm stuck.

I'd like to use a collection (actually, a Set) of Enum in my entity bean.
When using a single Enum, you just have to add the "@Enumeration(EnumType.STRING)" annotation, and it works. With a collection, it's does not, and the server complains that my Enum doesn't have a default constructor (you cannot add public constructors with Enum).

I thought about changing my Enum collection to a String collection, but I think it's dirty coding, and I'd like to find a nicer way to do that.

Here a snippet to illustrate the problem :

Java Code:
@Entity
public class User implements Serializable {
   [...]
   @ManyToMany
   [@Enumerated(EnumType.STRING)] // I tested with and without this line
   private Set<Role> roles;
 
   // Getters - Setters
}
 
// Other file
public enum Role {
   USER,
   POWER_USER,
   ADMIN;
 
   // Custom constructor (can't be public)
}
I somebody could answer that, I'd be very happy :)

Thanks !