您知道如何将此属性(Calendar数组)传递给@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"]'
答案 0 :(得分:0)
据我从删除语句中了解到,business_hours.hours
被输入为DB中的一个字符。所以你需要的是将数组序列化为符合数据库预期格式的String,然后通过单个占位符传递该String:
query = "delete from business_hours where company_address_id = ?1 and hours = ?2"