[JAVA-358] Enums are not serialized without transformation Created: 27/May/11 Updated: 25/Jun/13 Resolved: 27/May/11 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Robert Stiller | Assignee: | Antoine Girbal |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Enums cannot be serialized without transforming them. I propose, that all java enums are serialized (and deserialized) using the name() method (or valueOf() method). Example (using QueryDSL): @Entity public class MyObject { protected Type type; public Type getType() { public void setType(Type type) { this.type = type; }} Usage: QMyObject.myObject.type.eq(Type.TYPE1); // ends in: java.lang.IllegalArgumentException: can't serialize class Type |
| Comments |
| Comment by Robert Stiller [ 27/May/11 ] |
|
Same goes for java.util.Locale - it is one of the essential Types in Java! I propose the Serialization as follow: myLocale.toString(); and the Deserialization: Copied from org.springframework.util.StringUtils.parseLocaleString(String): String[] parts = tokenizeToStringArray(localeString, "_ ", false, false); } |