Envers Map<Enum, Integer> causes NullPointerException when mapped with @MapKeyEnumerated since Hibernate 5.4.6

Description

It seems fixed Map<Enum, Entity> mappings which use @MapKeyEnumerated, but in the process this inadvertedly broke Map<Enum, ?> mappings for which "?" is anything else instead of an entity.

This is the stacktrace we get since upgrading to 5.4.6:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Caused by: java.lang.NullPointerException at org.hibernate.envers.configuration.internal.ClassesAuditingData.addMapEnumeratedKey(ClassesAuditingData.java:194) at org.hibernate.envers.configuration.internal.ClassesAuditingData.updateCalculatedProperty(ClassesAuditingData.java:119) at org.hibernate.envers.configuration.internal.ClassesAuditingData.updateCalculatedFields(ClassesAuditingData.java:87) at org.hibernate.envers.configuration.internal.EntitiesConfigurator.configure(EntitiesConfigurator.java:72) at org.hibernate.envers.boot.internal.EnversServiceImpl.doInitialize(EnversServiceImpl.java:152) at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:116) at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:101) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:296) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:473) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:84) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:689) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:615) at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774) ... 135 more

This is an example mapping that breaks because of this:

1 2 3 4 5 6 7 8 9 10 11 12 13 @Audited @AuditJoinTable(name = "subs_p_crd_type_init_crd_aud") @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name = "subs_plan_crd_type_init_crd", joinColumns = @JoinColumn(name = "subscription_plan_id", nullable = false, foreignKey = @ForeignKey(name = "s_p_crd_type_init_crd_s_p_fk"))) @Fetch(FetchMode.SELECT) @BatchSize(size = 100) @MapKeyEnumerated(EnumType.STRING) @MapKeyColumn(name = "credit_type", length = 20, nullable = false) @Column(name = "initial_credits", nullable = false) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public Map<SubscriptionCreditType, Integer> getInitialCredits() { return initialCredits; }

Environment

None

Status

Assignee

Chris Cranford

Reporter

Manuel Dominguez Sarmiento

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.4.5

Components

Affects versions

5.4.6

Priority

Critical
Configure