【发布时间】:2021-04-19 11:47:28
【问题描述】:
有没有办法在 H2 上为current_timestamp 设置一个固定值?
我有一个使用 H2 运行的测试,它使用 current_timestamp 来确定寄存器是否处于活动状态,如下所示:
select t from MyTable t
where t.enabled = true
and current_timestamp between t.startDate and t.endDate
我想在此测试中为 current_timestamp 设置一个固定(也称为模拟)值,以避免在最终 current_timestamp 大于 e.endDate 时破坏此测试。
还有其他更好的方法来让它运行吗? 我想避免将 current_timesamp 作为查询参数传递。
【问题讨论】:
标签: spring-boot jpa h2 jpql