kundera icon indicating copy to clipboard operation
kundera copied to clipboard

Please advise on persisting enum property of a supercolumn class

Open rsumibcay opened this issue 14 years ago • 4 comments

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);
}

}

rsumibcay avatar Jun 07 '12 22:06 rsumibcay

https://github.com/impetus-opensource/Kundera/issues/67. This is not yet supported in Kundera.

mevivs avatar Jun 08 '12 04:06 mevivs

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!

rsumibcay avatar Jun 08 '12 17:06 rsumibcay

I would prefer option1 and get pojos generated with simpletype.

-Vivek

mevivs avatar Jun 08 '12 17:06 mevivs

Thanks Vivek.

rsumibcay avatar Jun 08 '12 21:06 rsumibcay