Closed buiminhhuy closed 9 years ago
This has been fixed by saving the Collection of Enums as a comma separated String in the Graph. So in the example above a String "USER,ADMINISTRATOR" will be saved to the graph if the Set contains both enums.
Also, the Collection declaration must be a concrete type, unless you use the new @EnumeratedCollection annotation where you can specify the concrete type of the Collection. So in the example above, you can change the declaration to:
private HashSet< Role > roles;
// OR
@EnumeratedCollection(HashSet.class)
private Set< Role > roles;
Enum: public enum Role { USER, ADMINISTRATOR }
Class: UserAccount{ @Enumerated(STRING) private Set< Role > roles; public Set< Role > getRoles() { return roles; } .... //other properties }
When save by Respository, then I use as below:
Set< Role > roles = userAccount.getRoles(); for (Role role : roles) { //todo
}
I get Error at statement: "for (Role role : roles) {" java.lang.ClassCastException: java.lang.String cannot be cast to.Role