is it possible to manully add keys to the map of Hibernate query cache?
Please see my reasoning below:
I have a query as follows:
from UserTable as u where u.username="Dan" and password="123456"
And the result query returns a user with the id of 3.
The first query is only executes once, and loaded to the query cache.
Now, while the first result is cached, I issue the following query
from UserTable as u where u.id=3
Which will return the same user, but as I learnt from various site, like so, the queries will be treated as different queries entirely by the cache (please correct me if I'm wrong of course).
Is there a way to tell Hibernate that both queries return the same data? Doing so will save hibernate from hitting the database the second time.
A theoretical solution I can think of is, after issuning the first query, inject the second query with the first query value to the cache, but I'm not sure it's possible.