I am not having any idea how to use Enum in @ColumnResult Type while using @ConstructorResult of @SqlResultSetMapping
@SqlResultSetMapping(name="DetailAndResult",
classes={
@ConstructorResult(targetClass=DetailAndResult.class, columns={
@ColumnResult(name="id", type= String.class),
@ColumnResult(name="runId", type=Integer.class),
@ColumnResult(name="subRunId", type=Integer.class),
@ColumnResult(name="transactionId", type=Integer.class),
@ColumnResult(name="referenceNumber", type=String.class),
@ColumnResult(name="customerName", type=String.class),
@ColumnResult(name="transactionType", type=TransactionType.class),
@ColumnResult(name="transactionResultStatus", type=String.class)
})
}
)
in above configuration, name 'transactionType' is of TransactionType Enum. What is the correct way to use Enum here.
if above is the correct way then I am getting this exception (If I will remove the Enum field then there is no exception) so thinking that there should be another way to use this.
Caused by: javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_51]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_51]
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:333) ~[spring-orm-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at com.sun.proxy.$Proxy146.getResultList(Unknown Source) ~[na:na]
With hibernateTemplate, we were using sqlquery.addscalar and there was a way to use Enum there using org.hibernate.type.Type and
TypeLocatorImpl(new TypeResolver()).custom(EnumType.class, params)
Please suggest if something like this will be used for @SqlResultSetMapping and @ConstructorResult