我正在尝试使用来自存储库界面的以下查询读取从数据库中获取的数据:
public interface EventObjectRepository extends CrudRepository<EventObject, Long> {
@Query(value = "select tb.content from table0 tb where tb.id=:id", nativeQuery = true)
List<String> find(@Param("id") Long id);
}
下面是我从这个查询中得到的结果的示例快照,它存储在一个 java 列表中: List<String> results
[clob1: '{"identity":0,"original_text":"some text","rowid":2}', clob2: '{"identity":2,"original_text":"some text","rowid":3}', clob3: '{"identity":3,"original_text":"some text","rowid":4}', clob4: '{"identity":4,"product.name":"some name","original_text":"some text","commodity.name":"some name","rowid":5}']
但是,当我尝试使用例如访问列表的内容时:
results.get(1)
我收到以下错误:
[ERROR] 2018-10-22 13:44:45.113 [http-nio-8090-exec-1] [dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.Cla
ssCastException: com.sun.proxy.$Proxy164 cannot be cast to java.lang.String] with root cause
java.lang.ClassCastException: com.sun.proxy.$Proxy164 cannot be cast to java.lang.String
我应该怎么做才能得到结果字符串?
慕田峪9158850
小唯快跑啊
拉丁的传说
相关分类