提取日期时休眠查询错误

时间:2019-01-09 17:10:09

标签: java spring hibernate datetime jhipster

请,请参阅错误日志后的更新


我在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"
}

在我看来解决方案接近(?)

0 个答案:

没有答案