Uploaded image for project: 'Hibernate ORM'
  1. HHH-12587

Flushing enhanced entity with @Cache(usage = CacheConcurrencyStrategy.NONE) fails

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      Given enhanced entity (enableLazyInitialization=true, everything else=false) using @Cache(usage = CacheConcurrencyStrategy.NONE)

      @Entity
      @Cache(usage = CacheConcurrencyStrategy.NONE)
      public class NoCacheConcurrencyStrategyEntity {
      
      	@Id
      	@GeneratedValue
      	public int id;
      }
      

      When this entity is saved with enabled second level cache, the following exception is raised:

      javax.persistence.PersistenceException: org.hibernate.HibernateException: Illegal attempt to build cache entry for non-cached entity
      
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
      	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1458)
      	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1438)
      	at org.hibernate.bugs.enhancement.SecondLevelCacheTestCase.hhh12425(SecondLevelCacheTestCase.java:57)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.hibernate.HibernateException: Illegal attempt to build cache entry for non-cached entity
      	at org.hibernate.persister.entity.AbstractEntityPersister$NoopCacheEntryHelper.buildCacheEntry(AbstractEntityPersister.java:5524)
      	at org.hibernate.persister.entity.AbstractEntityPersister.buildCacheEntry(AbstractEntityPersister.java:4460)
      	at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:113)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
      	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356)
      	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1452)
      	... 17 more
      

      Using a difference CacheConcurrencyStrategy works fine.

      Test case: https://github.com/nikowitt/hibernate-test-case-templates/tree/HHH-12587

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: