org.hibernate.Query#setParameter(String, Object) is extremely slow

Description

Hi,

this issue is present in both 5.2.17 and 5.4.0. It wasn't present in 4.3.x we used before.

The thing is that org.hibernate.Query#setParameter(String, Object) is now much slower that it used to be.
We have a customer that generates query with 50000 parameters, and now it takes 30s to just set these params. The issue is lookup into map values in ParameterMetadataImpl#containsReference that is called for every param internally in hibernate. Adding a cache here, reduces the time to set the params to 1s on my machine.

Will attach pull request. For us, the severity is critical, so we went with custom build of hibernate, but it would be nice if that can also be fixed in upstream.

Thanks,
Tomas

Environment

None

Assignee

Tomas Lamr

Reporter

Tomas Lamr

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