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

Ambiguous attribute converters invalidly reported for field of generic type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 5.1.0
    • Fix versions: 5.1.1
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      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:

      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:

      @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:

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

      Steps to reproduce:

      $ 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
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: