We're updating the issue view to help you get more done. 

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

Description

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

1 2 3 4 5 6 7 8 @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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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

Environment

None

Status

Assignee

Chris Cranford

Reporter

Niko Wittenbeck

Fix versions

Affects versions

5.3.0.Final

Priority

Major