org.hibernate.query.Query<R> setProperties(Map map); set to null parameters not contained in the map

Description

Example
Query query = session.createQuery("SELECT user FROM User user WHERE user.id IN (:ids) AND user.status IN (:statuses)");
query.setParameterList("statuses",statusList);
map.put("ids", idList);
query.setProperties(map);

The parameter statuses is wrongly set to null.

Environment

None

Activity

Show:
Andrea Boriero
June 3, 2016, 1:38 PM
Miroslav Šilhavý
June 3, 2016, 1:48 PM

Actually there are two bugs hidden in this one.
1. First when I use setParameter

This query works, but the setProperties actually overwrites the value with NULL set up already by setParameter.

2. I use setParameterList

Then query fails on different number in namedParameters.size() + namedParametersList.size() in AbstractQueryImpl#verifyParameters(). As the setProperties map set ups 2 parameters inside namedParameters and 1 parameter in namedParameterLists. But apparently number of parameters is only 2.

I believe that something like map.contains() check in setProperies could fix both issue.

Gail Badner
June 13, 2016, 11:42 PM

Fixed in master, 5.2, and 5.1.

Assignee

Andrea Boriero

Reporter

Andrea Boriero

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure