[hibernate-dev] Natural ID caching bug?

Steve Ebersole steve at hibernate.org
Fri Mar 30 12:37:29 EDT 2012


https://hibernate.onjira.com/browse/HHH-7210

Found some other minor problems.  Pushing fixes...

On Fri 30 Mar 2012 11:28:28 AM CDT, Steve Ebersole wrote:
> You mean the stats aren't being updated... Yes, that does look like an
> oversight.
>
> On Fri 30 Mar 2012 09:01:36 AM CDT, Galder Zamarreño wrote:
>> 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 at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
> --
> steve at hibernate.org
> http://hibernate.org

--
steve at hibernate.org
http://hibernate.org



More information about the hibernate-dev mailing list