I have some questions on 2nd level query caching. Does 2nd level caching only allows caching of entities that have a mapping with database.
Suppose if I fetch a query with projection, with selected columns , is it able to cache the query that return columns for different tables
Suppose if I do this
Query q = session.createQuery("select p.name,s.salAmount from Person p
join p.salary s where p.age > 25");
query.setCachemode(CacheMode.NORMAL);
query.setCacheable(true);
query.setCachregion("query.cachreGion);
query.list();
Is this kind of query cachable or do I need to select the whole row with salary assosciation such as
("select p from Person p left join fetch p.salary s where p.age > 25")
to make this query cacheble
Thanks
|