I'm looking for a way how to retrieve last generated keys/ids from insert performed via "createNativeQuery" in similar way like "getGeneratedKeys" in PreparedStatement.
As I wrote in first paragraph, I know there is a possibility to use PreparedStatement which actually works and we are using it for some different cases. Also I know that I can do direct select into database and call "LAST_INSERT_ID" or "@@Identity" which also works, but that's a way I want to avoid. For now I've been using inserting rows into DB and then I was calling simple "LAST_INSERT_ID()" and retrieve the id.
I want to avoid this because it works until I started to testing ProxySQL, which, I guess, do some stuff with connections/sessions and when I call LAST_INSERT I will just get zero value (but when I try the same with Prepared statements and getGeneratedKeys, it works)
There are dozens of similar stack topics like this, but I didn't find a single answer.
I've been playing around with getResultList and getLastResult Query methods, but nothing leads to a success way how to retrieve last generated ids.