|
After inserting new entity and committing, queries by natural-id of this entity are stil miss in natural-id cache. Then I track the source code of org.hibernate.engine.internal.StatefulPersistenceContext at line 1932:
1930: public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { 1931: if (success) { 1932: final boolean put = naturalIdCacheAccessStrategy.afterInsert( naturalIdCacheKey, id ); ...
This 'id' passed to method 'afterInsert' is null, which causes a natural-id cache entry with null identifier value put into the cache region. So the following queries by this natural-id will always miss even if the cache entry is actually exist.
|