【发布时间】:2016-04-30 20:19:27
【问题描述】:
你知道如何将这个属性(日历数组)传递给@NamedNativeQuery 吗?
'["1996-01-01 12:00:00","1996-01-01 17:00:00"]'
我尝试了以下方法但不起作用。
@NamedNativeQuery(
name = "BusinessHours.deleteBusinessHours",
query = "delete from business_hours " +
"where company_address_id = ?1 and " +
"hours = [?2,?3]"
)
编辑: postgres 中的原生查询是:
DELETE FROM business_hours
WHERE company_address_id = 7
AND hours = '["1996-01-01 18:15:00","1996-01-01 18:30:00"]'
【问题讨论】:
-
你试过了吗? ...和 ?2 中的小时数并传递数组而不是 2 个参数
-
看不懂你能不能写的详细一点。
-
query = "delete from business_hours where company_address_id = ?1 and hours in ?2" As ?2 你传递日期数组
-
不,它不再起作用了..
-
尝试查询 =“从 business_hours 中删除 company_address_id = ?1 和 hours = ARRAY[?2, ?3]”