Upgrading from Spring Data JPA 4.0.4 to 4.0.5 (via Spring Boot 4.0.5 → 4.0.6) breaks every JpaRepository<E, ID> where E is an @entity that inherits its @id from a @MappedSuperclass. Spring Data JPA 4.0.4 with the same Spring Boot 4.0.6 setup works correctly.
Reproducer:
@MappedSuperclass
public abstract class AbstractEntity {
@id private UUID id;
}
@entity @table(name = "T_FOO")
public class FooEntity extends AbstractEntity {
@column private String name;
}
public interface FooRepository extends JpaRepository<FooEntity, UUID> {}
Environment: Spring Boot 4.0.6, Spring Data JPA 4.0.5, Hibernate 7.3.2.Final, Java 21.
Workaround: Pinning spring-data-jpa and spring-data-commons to 4.0.4 fixes the issue.
Stacktrace (anonymised):
Caused by: java.lang.IllegalArgumentException:
This class [class com.example.entity.FooEntity] does not define an IdClass
at org.hibernate.metamodel.model.domain.internal.AbstractIdentifiableType
.getIdClassAttributes(AbstractIdentifiableType.java:216)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata
.findAttributes(JpaMetamodelEntityInformation.java:331)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata
.(JpaMetamodelEntityInformation.java:319)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation
.(JpaMetamodelEntityInformation.java:118)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport
.getEntityInformation(JpaEntityInformationSupport.java:98)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport
.getEntityInformation(JpaEntityInformationSupport.java:73)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory
.getEntityInformation(JpaRepositoryFactory.java:270)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory
.getRepositoryFragments(JpaRepositoryFactory.java:300)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory
.getRepositoryFragments(JpaRepositoryFactory.java:280)
at org.springframework.data.repository.core.support.RepositoryFactorySupport
.lambda$getRepositoryStub$0(RepositoryFactorySupport.java:497)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)
at org.springframework.data.repository.core.support.RepositoryFactorySupport
.getRepositoryStub(RepositoryFactorySupport.java:494)
at org.springframework.data.repository.core.support.RepositoryFactorySupport
.getRepository(RepositoryFactorySupport.java:334)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport
.lambda$afterPropertiesSet$1(RepositoryFactoryBeanSupport.java:361)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:136)
at org.springframework.data.util.Lazy.get(Lazy.java:114)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport
.afterPropertiesSet(RepositoryFactoryBeanSupport.java:370)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean
.afterPropertiesSet(JpaRepositoryFactoryBean.java:212)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1864)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean(AbstractAutowireCapableBeanFactory.java:1813)
Upgrading from Spring Data JPA 4.0.4 to 4.0.5 (via Spring Boot 4.0.5 → 4.0.6) breaks every JpaRepository<E, ID> where E is an @entity that inherits its @id from a @MappedSuperclass. Spring Data JPA 4.0.4 with the same Spring Boot 4.0.6 setup works correctly.
Reproducer:
@MappedSuperclass
public abstract class AbstractEntity {
@id private UUID id;
}
@entity @table(name = "T_FOO")
public class FooEntity extends AbstractEntity {
@column private String name;
}
public interface FooRepository extends JpaRepository<FooEntity, UUID> {}
Environment: Spring Boot 4.0.6, Spring Data JPA 4.0.5, Hibernate 7.3.2.Final, Java 21.
Workaround: Pinning spring-data-jpa and spring-data-commons to 4.0.4 fixes the issue.
Stacktrace (anonymised):
Caused by: java.lang.IllegalArgumentException:
This class [class com.example.entity.FooEntity] does not define an IdClass
at org.hibernate.metamodel.model.domain.internal.AbstractIdentifiableType
.getIdClassAttributes(AbstractIdentifiableType.java:216)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata
.findAttributes(JpaMetamodelEntityInformation.java:331)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata
.(JpaMetamodelEntityInformation.java:319)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation
.(JpaMetamodelEntityInformation.java:118)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport
.getEntityInformation(JpaEntityInformationSupport.java:98)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport
.getEntityInformation(JpaEntityInformationSupport.java:73)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory
.getEntityInformation(JpaRepositoryFactory.java:270)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory
.getRepositoryFragments(JpaRepositoryFactory.java:300)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory
.getRepositoryFragments(JpaRepositoryFactory.java:280)
at org.springframework.data.repository.core.support.RepositoryFactorySupport
.lambda$getRepositoryStub$0(RepositoryFactorySupport.java:497)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)
at org.springframework.data.repository.core.support.RepositoryFactorySupport
.getRepositoryStub(RepositoryFactorySupport.java:494)
at org.springframework.data.repository.core.support.RepositoryFactorySupport
.getRepository(RepositoryFactorySupport.java:334)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport
.lambda$afterPropertiesSet$1(RepositoryFactoryBeanSupport.java:361)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:136)
at org.springframework.data.util.Lazy.get(Lazy.java:114)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport
.afterPropertiesSet(RepositoryFactoryBeanSupport.java:370)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean
.afterPropertiesSet(JpaRepositoryFactoryBean.java:212)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1864)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean(AbstractAutowireCapableBeanFactory.java:1813)