Hi guys,

I think there's a bug in the Natural ID support impl in Hibernate and wanted to 
confirm with you:

For entity caching, EntityInsertAction does:

boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, 
version );                     
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
  factory.getStatisticsImplementor().secondLevelCachePut( 
getPersister().getCacheAccessStrategy().getRegion().getName() );
}

But for natural id caching, insert() return is ignored and only afterInsert()'s 
result is taken into accound:

NaturalIdXrefDelegate:

case INSERT: { 
   naturalIdCacheAccessStrategy.insert( naturalIdCacheKey, pk );

  ( (EventSource) session() ).getActionQueue().registerProcess(
     new AfterTransactionCompletionProcess() {
        @Override
        public void doAfterTransactionCompletion(boolean success, 
SessionImplementor session) {
                final boolean put = naturalIdCacheAccessStrategy.afterInsert( 
naturalIdCacheKey, pk );

                if ( put && justAddedToLocalCache && 
factory.getStatistics().isStatisticsEnabled() ) {
                   factory.getStatisticsImplementor().naturalIdCachePut(
                naturalIdCacheAccessStrategy.getRegion().getName() );

>From what I've understood, both natural id caching and entity caching should 
>behave in the same way.

Infinispan does not implement afterInsert() because it's not an asynchornous 
caching strategy, so natural id cache puts on insert are not currently being 
updated.

Cheers,
--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache


_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to