Does native query in JPA (createNativeQuery
) supports caching?
I am filling my own data transfer object because the sql query joins several tables and takes only several columns form them.
Regards
In JPA, you can create a query using entityManager. createQuery() . You can look into API for more detail. Native query refers to actual sql queries (referring to actual database objects).
JPA has 2 levels of caching. The first level of caching is the persistence context. The JPA Entity Manager maintains a set of Managed Entities in the Persistence Context.
Native query refers to actual sql queries (referring to actual database objects). These queries are the sql statements which can be directly executed in database using a database client. 2. Named query is the way you define your query by giving it a name.
This is possible but you must use an explicit .addScalar
or .addEntity
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With