Please advise on persisting enum property of a supercolumn class
Hello,
I have a supercolumn class that has an enum property. When attempting to persist my CartType, an org.cloner.CloneException is thrown, with root cause java.lang.InstantiationException of DeliveryTypeType.
Please help on the proper annotations to allow my CartType instance w/ enum propert to be persisted into Cassandra.
Thanks!
//---------------- // My entity class // -----------------
@Entity @Table(name = "carts", schema = "webcart@cassandra_pu") public class CartType {
@Id
protected String persistenceId;
@Column
protected String id;
@Column
protected String accountNumber;
@ElementCollection
protected List<PackageType> packages;
@Embedded
protected PersonalInfoType personalInfo;
@Enumerated
protected DeliveryTypeType deliveryType = DeliveryTypeType.S; //This causes java.lang.InstantiationException
}
// ---------------- // DeliveryTypeType enum // ---------------- @Embeddable public enum DeliveryTypeType {
S,
P;
public DeliveryTypeType(){}
public String value() {
return name();
}
public static DeliveryTypeType fromValue(String v) {
return valueOf(v);
}
}
https://github.com/impetus-opensource/Kundera/issues/67. This is not yet supported in Kundera.
The pojos we are attempting to persist are generated from XSDs via JAXB. I'm thinking we would have two options:
Option 1: Change our XSD definitions so that the constraints of our simpletypes are not defined using enumerated values. Instead, redefine constraints to use regex patterns. Option 2: Using Spring, some how plugin our own persistence logic to persist the enum type. I have a lack of knowledge of JPA, so I don't know where to begin with this one.
Do you have any recommendations?
Thanks!
I would prefer option1 and get pojos generated with simpletype.
-Vivek
Thanks Vivek.