For performance reasons I need to use some native queries to insert new objects into a database. I have a very sophisticated JPA persistence layer which manages my usual entity reading and writing and I would like to use this persistence layer to run the native queries.
I know I need the methods EntityManager#createNativeQuery(String) and Query#executeUpdate to achieve my goal.
My current problem is that I would also like to get the generated identifier of the newly inserted row. I know this is possible using JDBC or SpringPersistence but is there any way to get those identifiers from a JPA native query?