我从数据库中下载记录时遇到问题,该数据库中的日期形式如下:2018-10-14(日期)
该字段在数据库中的结构如下所示:next_day DATE NOT NULL
调用 findDay 方法时,会抛出异常:
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: date <= bytea
一个方法:
open fun findDay(day: LocalDate) : Day {
val sql = "SELECT bbd FROM com.test.entity.Day d WHERE d.nextDay <= :nextDay ORDER BY d.nextDay DESC"
val query: TypedQuery<Day> = entityManager.createQuery(sql, Day::class.java)
query.setParameter("nextDay", day)
query.maxResults = 1
return query.singleResult
}
实体:
@Entity(name="day")
open class Day {
@Id
var id: Long? = null
@Column(name = "next_day")
var nextDay: LocalDate? = null
}
有没有办法从数据库中获取行?
不负相思意
慕姐8265434
相关分类