Cannot replace an existing JPQL NamedQuery with a native NamedQuery

Description

From :

I discovered a weird behavior working in KEYCLOAK-18842. The main problem in that JIRA is that there is a bug in mariadb/mysql that makes a delete with a subquery terribly slow (MDEV-21012). I was trying to just use the addNamedQuery method to replace that named query with a native implementation for those engines at runtime/startup. But it doesn't work because it seems that the NamedQueryRepository stores them in two different maps and the jpql one is always tried first when the createNamedQuery method is called. Reading the javadoc for the addNamedQuery I think this is a bug, replacing a jpql query with a native one is impossible right now.

I implemented a tentative fix for this with this commit. There is a test which exemplifies the problem better than this description.

WDYT? Is the PR worthy? You can use or extend it if necessary...

Thanks a lot!

Activity

Show:

Sanne Grinovero September 8, 2021 at 4:00 PM

NP, did all the work

Former user September 8, 2021 at 3:57 PM

, thanks for your help on this!

Ricardo Martin Camarero September 3, 2021 at 7:12 AM

I have submited a PR for this:

Any improvement will be welcomed!

Fixed

Details

Assignee

Reporter

Components

Affects versions

Priority

Created September 2, 2021 at 7:26 PM
Updated September 23, 2021 at 4:08 PM
Resolved September 7, 2021 at 11:30 AM