java - 提取日期时出现休眠查询错误
问题描述
请参阅错误日志后的更新
我在 spring 应用程序中有这样的代码:
@Query("SELECT e.status FROM EquipmentContract e")
List<String> getTerminationDates();
它有效。但是如果我更改查询,添加datetime
类型的字段
@Query("SELECT e.status, e.terminated_date FROM EquipmentContract e")
它没有,向我暴露了这样的错误日志:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration' defined in file [C:\Users\sergei.klevtsov\Documents\Projects\Work\ntt-inventory\target\classes\com\acn\inventory\config\SecurityConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 5; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.zalando.problem.spring.web.advice.security.SecurityProblemSupport': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'handlerExceptionResolver' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerExceptionResolver]: Factory method 'handlerExceptionResolver' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'equipmentContractRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.acn.inventory.repository.EquipmentContractRepository.getTerminationDates()!
查询中是否应该使用一些额外的结构来处理datatime
或......?
经过一些更改后,编译时的错误消失了,但现在在加载 REST 源代码后它说:
{
"type" : "http://www.jhipster.tech/problem/problem-with-message",
"title" : "Internal Server Error",
"status" : 500,
"detail" : "Could not write JSON: java.sql.Timestamp cannot be cast to [Ljava.lang.Object;; nested exception is com.fasterxml.jackson.databind.JsonMappingException: java.sql.Timestamp cannot be cast to [Ljava.lang.Object; (through reference chain: java.util.ArrayList[0])",
"path" : "/api/equipment-contracts/terminations/dates",
"message" : "error.http.500"
}
在我看来,解决方案就在附近(?)
解决方案
推荐阅读
- python - 如何在 Python 中将线程用于 Selenium 的并行实例?
- r - 为什么 %>% unnest() 在 R 中产生两倍的行数
- r - 从函数参数中动态命名列表元素
- google-apps-script - 如何根据 Google 表格中的单元格值更改行高?
- ruby-on-rails - GitHub Codespaces 子域
- r - 在同一行中分组和过滤
- android - 当应用程序在后台/被杀死时,在 Firebase onMessageReceived 中调用暂停 apiFetch 请求
- javascript - 如何仅在电子应用程序中复制和粘贴突出显示的文本?
- python - 分发项目时包含外部 Python 模块的最佳方式是什么?
- r - 如何创建这个序列 "x-^-1" "x-^-1" "x-^-1" "x-^-1" "x-^-2" "x-^-2" "x- ^-2" "x-^-3" "x-^-3" "x-^-4" 在 R 中?