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

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

1
  • 01 Sep 2016, 01:10 PM

Web links

Activity

Show:

Former user January 10, 2018 at 6:51 AM

Fixed in 5.2 and 5.1 branches.

Former user January 8, 2018 at 7:52 PM

I've removed the 5.3.0.Beta1 fix version because hibernate-infinispan is no longer in Hibernate ORM.

For 5.3.0.Beta1, this will be fixed by https://issues.jboss.org/browse/ISPN-8601.

Steve Ebersole January 5, 2018 at 5:55 PM

FYI I will be releasing 5.3 Beta1 1/10.

Galder Zamarreno December 15, 2017 at 8:00 AM

Galder Zamarreno December 13, 2017 at 3:43 PM

Fixed

Assignee

Galder Zamarreno

Reporter

Components

Fix versions

Affects versions

Priority

Created January 6, 2016 at 9:53 AM
Updated April 25, 2018 at 7:38 PM
Resolved January 10, 2018 at 6:51 AM