We're updating the issue view to help you get more done. 

Ambiguous attribute converters invalidly reported for field of generic type

Description

In contrast to version 5.0.7, on 5.1.0 my JPA bootstrap fails reporting multiple converters being applicable to a generic field of an entity:

1 2 3 4 5 6 7 8 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in org.springframework.data.jpa.convert.threeten.Jsr310JpaConvertersIntegrationTests$Config: Invocation of init method failed; nested exception is java.lang.RuntimeException: Multiple auto-apply converters matched attribute [org.springframework.data.jpa.domain.AbstractPersistable.id] : org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters$LocalDateConverter, org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters$InstantConverter, org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters$LocalTimeConverter, org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters$ZoneIdConverter, org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters$LocalDateTimeConverter

AbstractPersistable uses generics bound to Serializable to define a primary key:

1 2 3 4 5 6 7 @MappedSuperclass public abstract class AbstractPersistable<PK extends Serializable> implements Persistable<PK> { private static final long serialVersionUID = -5554308939380869754L; @Id @GeneratedValue private PK id; …

The converters reported are referring to JSR-310 date time types:

1 2 @Converter(autoApply = true) public class LocalDateConverter implements AttributeConverter<LocalDate, Date> { … }

Steps to reproduce:

1 2 3 4 5 6 $ git clone https://github.com/spring-projects/spring-data-jpa $ cd spring-data-jpa $ mvn clean test -Phibernate-5 … log output ending in successful build $ mvn clean test -Phibernate-51 … log output throwing above mentioned exception

Environment

None

Status

Assignee

Unassigned

Reporter

Oliver Gierke

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.1.0

Priority

Major