I have 2 entities: User and Item, both @Cacheable. Item has @ManyToOne private User user. Level 2 JPA cache is activated and it works ok for find by id (tested by changing data in explorer and reading in my app).
Problem 1: find by id on Item it's good, it hits the cache, but not for its field "user". "user" is loaded each time from the DB (tested by changing data in explorer and reading in my app). "user" should also be taken from L2 cache, shouldn't it? Otherwise...it's a huge performance hit.
Problem 2: executing a query that returns User with id 5,6,7 (or any other) takes fresh data each time, even though user 5 has been previously loaded by find by id and its class is @Cacheable. Shouldn't just 6 and 7 be returned fresh (the first time, then loaded from L2 Cache each time)?
I didn't encounter P1 and 2 while using EclipseLink & MySQL.
Thanks in advance.