setParameter doesn't work in native Query if Query is already executed with different parameter value for collection type when new collection length is less than the previous

Description

setParameter doesn't work if Query is already executed with different parameter value for collection type when new collection length is less than the old.

1 2 3 4 5 Query query = getEntityManager().createNativeQuery("update student set status=:status, modification_time = CURRENT_TIMESTAMP where id in (:ids)"); query.setParameter("ids", Arrays.asList(1L,5L,3L)); query.executeUpdate(); query.setParameter("ids", Arrays.asList(5L,3L)); query.executeUpdate(); // exception

Caused by: org.hibernate.QueryException: Named parameter does not appear in Query: ids_2 [update student set status=?, modification_time = CURRENT_TIMESTAMP where id in (?, ?)]
at org.hibernate.engine.query.spi.NativeSQLQueryPlan.getNamedParameterLocs(NativeSQLQueryPlan.java:65)
at org.hibernate.engine.query.spi.NativeSQLQueryPlan.bindNamedParameters(NativeSQLQueryPlan.java:134)
at org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:200)
at org.hibernate.internal.SessionImpl.executeNativeUpdate(SessionImpl.java:1575)
at org.hibernate.query.internal.NativeQueryImpl.doExecuteUpdate(NativeQueryImpl.java:274)
at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1504)
... 29 more

Environment

None

Status

Assignee

Rabin Banerjee

Reporter

Rabin Banerjee

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Affects versions

5.2.18

Priority

Critical
Configure