I met the same ClassCastException recently, and I too think this is likely a but. Different usage scenario. In my case, at least, proper configuration of property mapping is not an issue.
I'm trying to pass Array of enum as a parameter to an HQL query.
Stacktrace:
Code:
Caused by: java.lang.ClassCastException: [Lweblock.model.ValidationStatus;
at org.hibernate.type.EnumType.nullSafeSet(EnumType.java:125)
at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:156)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:38)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:491)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1563)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
Here's the set up:
HQL where clause: (obligor.validationStatus in (:validationStatus))
SQL translation: where obligor0_.VALIDATION_STATUS in (?)
Code:
ValidationList[] list;
...
Query obligorQuery = entityManager.createQuery(hql);
obligorQuery.setParameter("validationStatus", list);
...
List<Obligor> obligors = obligorQuery.getResultList(); // Exception here
Enum definition:
Code:
public enum ValidationStatus {
CONVERTED("Converted"),PENDING("Pending"), VALID("Valid"), INVALID("Invalid");
private ValidationStatus(String displayValue) {
this.displayValue = displayValue;
}
private String displayValue;
public String getDisplayValue() {
return displayValue;
}
public void setDisplayValue(String displayValue) {
this.displayValue = displayValue;
}
Property Mapping:
Code:
@Enumerated (EnumType.STRING)
@Column(name="VALIDATION_STATUS",length=10)
public ValidationStatus getValidationStatus() {
return validationStatus;
}