当“in”表达式之一具有 1000 个或更多项目时,我有以下 Hibernate NamedQuery 会遇到问题。当我在 (:devices) 的 ma.deviceId 中有 1000 个或更多项目时,我得到java.sql.SQLException: ORA-01795: maximum number of expressions in a list is 1000
我需要处理的唯一“in”表达式是“and ma.deviceId in (:devices)”。有人对如何重写这个 NamedQuery 有任何想法吗?我正在使用 JPA 和休眠。
@NamedQuery(name = "Messages.findMessages", query = " SELECT ma from Messages ma JOIN FETCH ma.messagePayLoadXml mx LEFT OUTER JOIN FETCH ma.messageProperties mp " +
" WHERE ma.customerId = :customerId and ma.time >= :startTime and ma.time <= :endTime " +
" and ma.deviceId in (:devices) and mx.messageType = 'XML' and mx.alerts in " +
" ( select mtfm.messageType from MessageTypeFeatureMap mtfm where mtfm.feature in (:featureType) ) " +
" and ma.messageKey = mx.messageKey and ( mp.deleted = 0 or mp.deleted is null ) " +
" order by ma.time desc " )