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

Entity with EmbeddedId fails retrieve from cache after deployment reload

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: 5.2.2
    • Fix versions: None
    • Components: hibernate-core
    • Labels:
      None
    • Environment:
      WildFly 10
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

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

      Description

      I'm on WildFly 10, Hibernate 5.2.2 and a simple JAX-RS/JPA app with an entity like this:

      @Entity
      @Cacheable
      public class MyEntity implements Serializable {
      
          @EmbeddedId
          private MyEmbeddableId id;
      
          // other fields, hashCode, equals, getters and setters
      
      }
      
      @Embeddable
      public class MyEmbeddableId implements Serializable {
      
          private String foo;
      
          private String bar;
      
          // hashCode, equals, getters and setters
      
      }
      

      All works like expected, but if I reload the app (not restarting WildFly) then on entity load I get:

      org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [private java.lang.String MyEmbeddableId.foo] by reflection for persistent property [MyEmbeddableId#foo] : MyEmbeddableId@33675787
      	at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:71)
      	at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:58)
      	at org.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:414)
      	at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:225)
      	at org.hibernate.cache.infinispan.TypeEquivalance.hashCode(TypeEquivalance.java:24)
      	at org.infinispan.commons.util.concurrent.jdk8backported.BoundedEquivalentConcurrentHashMapV8.get(BoundedEquivalentConcurrentHashMapV8.java:2427)
      	at org.infinispan.container.DefaultDataContainer.get(DefaultDataContainer.java:188)
      	at org.infinispan.container.EntryFactoryImpl.innerGetFromContainer(EntryFactoryImpl.java:288)
      	at org.infinispan.container.EntryFactoryImpl.getFromContainer(EntryFactoryImpl.java:258)
      	at org.infinispan.container.EntryFactoryImpl.wrapEntryForReading(EntryFactoryImpl.java:64)
      	at org.infinispan.interceptors.EntryWrappingInterceptor.visitDataReadCommand(EntryWrappingInterceptor.java:132)
      	at org.infinispan.interceptors.EntryWrappingInterceptor.visitGetKeyValueCommand(EntryWrappingInterceptor.java:123)
      	at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:40)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
      	at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:113)
      	at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:85)
      	at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:40)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
      	at org.infinispan.interceptors.locking.PessimisticLockingInterceptor.visitDataReadCommand(PessimisticLockingInterceptor.java:71)
      	at org.infinispan.interceptors.locking.AbstractLockingInterceptor.visitGetKeyValueCommand(AbstractLockingInterceptor.java:77)
      	at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:40)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
      	at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:345)
      	at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:330)
      	at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:40)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:99)
      	at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:107)
      	at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:76)
      	at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:85)
      	at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:40)
      	at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:336)
      	at org.infinispan.cache.impl.CacheImpl.get(CacheImpl.java:411)
      	at org.infinispan.cache.impl.CacheImpl.get(CacheImpl.java:403)
      	at org.infinispan.cache.impl.AbstractDelegatingCache.get(AbstractDelegatingCache.java:286)
      	at org.hibernate.cache.infinispan.access.InvalidationCacheAccessDelegate.get(InvalidationCacheAccessDelegate.java:61)
      	at org.hibernate.cache.infinispan.entity.ReadOnlyAccess.get(ReadOnlyAccess.java:44)
      	at org.hibernate.engine.internal.CacheHelper.fromSharedCache(CacheHelper.java:32)
      	at org.hibernate.event.internal.DefaultLoadEventListener.getFromSharedCache(DefaultLoadEventListener.java:651)
      	at org.hibernate.event.internal.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:595)
      	at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:462)
      	at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)
      	at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278)
      	at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)
      	at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)
      	at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1218)
      	at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1101)
      	at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:639)
      	at org.hibernate.type.EntityType.resolve(EntityType.java:431)
      	at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:151)
      	at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
      	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1146)
      	at org.hibernate.loader.Loader.processResultSet(Loader.java:1005)
      	at org.hibernate.loader.Loader.doQuery(Loader.java:943)
      	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
      	at org.hibernate.loader.Loader.doList(Loader.java:2615)
      	at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2460)
      	at org.hibernate.loader.Loader.list(Loader.java:2422)
      	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
      	at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
      	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1458)
      	at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1426)
      	at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1398)
      	... 120 more
      Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field MyEmbeddableId.foo to MyEmbeddableId
      

      If I restart WildFly, it works again. Also, if I disable caching all works fine also after deployment reload.

      Debugging, I've found that in org.hibernate.property.access.spi.GetterFieldImpl.get, after WildFly restart we have:

      Class fieldDeclaringClass = field.getDeclaringClass();
      Class ownerClass = owner.getClass();
      fieldDeclaringClass.getName().equals(ownerClass.getName()) == true;
      fieldDeclaringClass.isAssignableFrom(ownerClass) == true;
      

      and after deployment reload:

      Class fieldDeclaringClass = field.getDeclaringClass();
      Class ownerClass = owner.getClass();
      fieldDeclaringClass.getName().equals(ownerClass.getName()) == true;
      fieldDeclaringClass.isAssignableFrom(ownerClass) == false; // !!!
      

      I don't know how this can happen, two classes with the same name which are not the same class.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: