I am trying to run a query in Oracle ibatis to fetch content of a table. One of the column 'CREATED_ON' is of TIMESTAMP datatype. When I try to convert this to String using TO_CHAR function I get the below exception.
The goal is to get a Map of column headers & values from this query. If I remove the TO_CHAR from the query, I get the result in the Map without any exceptions but the CREATED_ON column values are oracle.sql.TIMESTAMP@3524fead.
EXCEPTION
com.ctg.dms.exceptions.DMSApplicationException: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ctg/dms/dao/ibatis/oracle/AuditLogAccessControlSQLs.xml.
--- The error occurred while applying a result map.
--- Check the auditLogAccessControl.findAccessLogEntriesForFileExport-AutoResultMap.
--- Check the result mapping for the 'TO_CHAR(A.CREATED_ON)' property.
--- Cause: com.ibatis.common.beans.ProbeException: There is no WRITEABLE property named 'CREATED_ON)' in class 'java.lang.Object'at com.ctg.dms.dao.impl.sql.ibatis.AuditLogAccessControlDAOImpl.findAccessLogEntriesForFileExport(AuditLogAccessControlDAOImpl.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy11.findAccessLogEntriesForFileExport(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Ibatis XML Mapping
<statement id="findAccessLogEntriesForFileExport" resultClass="HashMap">
SELECT (SELECT VALUE FROM REF_DATA WHERE ID_REF_DATA = A.ID_EVENT_TYPE) EVENT_TYPE,
A.DESCRIPTION AS DESCRIPTION, U.USERNAME AS CREATED_BY, TO_CHAR(A.CREATED_ON, 'DD-MM-YYYY')
FROM AUDIT_LOG_ACCESS_CONTROL A
JOIN USER_DETAILS U ON A.CREATED_BY = U.ID_USER_DETAILS
ORDER BY A.CREATED_ON DESC
</statement>
I don't know Abatis, but it seems that it requires to map this field to a field in your java object. You should give this an function an alias (=> TO_CHAR(A.CREATED_ON, 'DD-MM-YYYY') CREATED_ON), and make sure that the type (VARCHAR2/STRING) match in your java defintion.