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

ClassCastException thrown in SessionFactoryImpl for named regions containing both entity and collection

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Test case:

      • using Hibernate 5.0.6 with ehcache;
      <?xml version="1.0" encoding="UTF-8"?>
      <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      		 xsi:noNamespaceSchemaLocation="http://www.ehcache.org/ehcache.xsd"
      		 updateCheck="false" monitoring="autodetect" dynamicConfig="true">
        <cache name="configurationCache" eternal="false" timeToLiveSeconds="3600" maxEntriesLocalHeap="500"/>
      </ehcache>
      
      • annotating the entity classes with @Cache
        @Entity
        @Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE, region = "someConfigurationCache")
        public class SomeConfiguration implements Serializable {
            @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
            @JoinColumn(name = "some_configuration_id", referencedColumnName = "id")
            @Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE, region = "otherConfigurationCache")
            private List<OtherConfiguration> confList;
        }
        
      • both "someConfigurationCache" and "otherConfigurationCache" are reused for entity and collection as well.
        The result is "org.hibernate.cache.ehcache.internal.nonstop.NonstopAwareEntityRegionAccessStrategy cannot be cast to org.hibernate.cache.spi.access.CollectionRegionAccessStrategy", because the method determineCollectionRegionAccessStrategy in SessionFactoryImpl finds a region with the name required, but it is an entity region, not a collection region.
        The same scenario works with 5.0.3.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                6 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: