0

I have a functionality where a list of A(Entity) objects is given which is being iterated to manipulate a functionality where in the iteration B(Entity)'s column value is fetched by C_ID and DATE multiple times(JPA method: findByCIdAndDate), there are possibilities that by the same C_ID and DATE are queried multiple times. How do we approach this performance-wise?.

Is this ok to have this functionality because this could be handled by default Hibernate cache?

FYI: There is no caching applied to the application.

Thomson Ignesious
  • 689
  • 1
  • 8
  • 25
  • 2
    First, check if this is a performance issue. If yes, this can be handled by Hibernate cache. Just out of curiosity. Why do you have ID and Date? Isn't the ID unique? – Simon Martinelli Apr 11 '23 at 14:11
  • I meant some other mapped id, not the primary key, let me edit it. – Thomson Ignesious Apr 11 '23 at 15:59
  • if you can cache the query results and want to just return those same results when the same parameters are used, that is called a query cache - caching in JPA/Hibernate usually refers to entity caches. Hibernate has a query cache (https://docs.jboss.org/hibernate/stable/core.old/reference/en/html/performance-querycache.html ) built overtop of the entity cache. You'll need to look at the specifics of such a cache to see if it'll fit your application as there are side effects of caching you'll have to live with. – Chris Apr 12 '23 at 17:27

0 Answers0