java - JPA find() and refresh() without shared cache -
i wonder if these methods equivalent when shared cache disabled:
@stateless public class entityservice { @persistencecontext private entitymanager em; public <t> t findentity1(class<t> clazz, long id) { return em.find(clazz, id); } public <t> t findentity2(class<t> clazz, long id) { t entity = em.find(clazz, id); em.refresh(entity); return entity; } }
these methods never called inside existing transaction. db exclusively accessed application using jpa , no trigger/stored procedure/other defined.
my guess equivalent, because:
- em.find() search shared cache (l2), it's empty (disabled)
- em.find() search own cache (l1), it's empty (no previous transaction = em new)
- em.find() access db
- em.refresh() access db second time, in scenario entity same
did miss something?
Comments
Post a Comment