我想将此 XML 发送到 api 服务器:XML 请求:<reconcile> <start_date>2018-04-08T11:02:44</start_date> <end_date>2018-04-08T11:02:44</end_date> <page>1</page></reconcile>JAXB 代码:@XmlRootElement(name = "reconcile")@XmlAccessorType(XmlAccessType.FIELD)public class Reconcile { @XmlElement(name = "start_date") @XmlJavaTypeAdapter(LocalDateTimeXmlAdapter.class) public LocalDateTime start_date; @XmlElement(name = "end_date") @XmlJavaTypeAdapter(LocalDateTimeXmlAdapter.class) public LocalDateTime end_date; @XmlElement(name = "page") public String page;SQL查询:public List<PaymentTransactions> transactionsByDate(LocalDateTime start_date, LocalDateTime end_date) throws Exception { String hql = "select e from " + PaymentTransactions.class.getName() + " e where e.created_at >= ? and e.created_at <= ?"; Query query = entityManager.createQuery(hql).setParameter(0, start_date).setParameter(1, end_date)); List<PaymentTransactions> paymentTransactions = (List<PaymentTransactions>) query.getResultList(); return paymentTransactions; }但是当我提出请求时,我得到:java.lang.IllegalArgumentException: Parameter value [2018-04-08T11:02:44] did not match expected type [java.util.Date (n/a)]在将日期值作为 SQL 查询的参数发送之前,是否需要转换它?或者我需要使用其他类型的日期?
添加回答
举报
0/150
提交
取消