Skip to content
This repository was archived by the owner on Dec 30, 2020. It is now read-only.

Missing implementation of getObject(String, Class<T>) method in CassandraResultSet #27

Open
maximevw opened this issue Apr 10, 2019 · 0 comments

Comments

@maximevw
Copy link

Assuming I execute a select query like this one:

SELECT id, ts_update FROM mytable ;

where ts_update is a timestamp.

I used the Cassandra JDBC wrapper with MyBatis 3.4.6. My column ts_update is mapped on field of type OffsetDateTime in a Java bean.

In this version of MyBatis, the mapping of the columns of type timestamp was implemented as following:

public OffsetDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
        Timestamp timestamp = rs.getTimestamp(columnName);
        return getOffsetDateTime(timestamp);
}

So, it worked with the current version of CassandraResultSet (3.1.0). But, when I updated MyBatis to the version 3.5.1, I got the following error:

Caused by: java.sql.SQLFeatureNotSupportedException: the Cassandra implementation does not support this method
	at com.github.adejanovski.cassandra.jdbc.AbstractResultSet.getObject(AbstractResultSet.java:136)
	at com.zaxxer.hikari.pool.HikariProxyResultSet.getObject(HikariProxyResultSet.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:69)
	at com.sun.proxy.$Proxy161.getObject(Unknown Source)
	at org.apache.ibatis.type.OffsetDateTimeTypeHandler.getNullableResult(OffsetDateTimeTypeHandler.java:38)
	at org.apache.ibatis.type.OffsetDateTimeTypeHandler.getNullableResult(OffsetDateTimeTypeHandler.java:28)
	at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:81)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:472)

The issue comes from the fact that the method getObject(String, Class<T>) is not implemented in CassandraResultSet but called by the new implementation of the OffsetDateTime handling:

public OffsetDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return (OffsetDateTime)rs.getObject(columnName, OffsetDateTime.class); 
}

So, the mentioned method should be implemented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant