• Post Reply Bookmark Topic Watch Topic
  • New Topic

Persistence cache  RSS feed

arief hidayat
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have another question..

I read article from ...
Wonseok Kim's blog about cache TopLink JPA

It state..

When you get entities which are not in the persistence context TopLink uses cached entities in the session cache(clones of cache entites are returned). But EntityManager.find() and a SELECT query behave differently. EntityManager.find() checks session cache first before goes to database, but a SELECT query doesn't check cache first and always goes to database. Although a query goes to database, it avoids rebuilding an entity and the entity in the session cache is reused(some performance gain).

I don't really get the last sentence.
What's in my perception is that.. (correct me if I'm wrong)
there is a pool (cache.. or whatever its name)
inside it there are instances of Entity classes.
When select query is performed..
it gets, let says.. a row..
"it avoid rebuild an entity" means it get the instance from the cache with the same primary key. Then it updates the instance's property (if there is any different from the data in the table row).
Is my understanding correct?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!