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

Ability to use parametrized type as AttributeConverter type parameter

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.5
    • Fix Version/s: 5.0.0.CR1, 4.3.11
    • Component/s: None
    • Labels:
      None
    • Environment:
      Java SE 7, Tomcat 7.0.47, MySQL 5.6
    • Last commented by a user?:
      true

      Description

      Implementations of AttributeConverter<X<Z>, Y> fail in Hibernate 4.3.0.Final (with hibernate-jpa-2.1-api 1.0.0.Final).

      The following declaration fails:

      import javax.persistence.AttributeConverter;
      import javax.persistence.Converter;
      
      @Converter
      public class CategoryConverter implements AttributeConverter<Set<Category>, String>
      

      But this one works:

      import javax.persistence.AttributeConverter;
      import javax.persistence.Converter;
      
      @Converter
      public class CategoryConverter implements AttributeConverter<Set, String>
      

      The exception is

      java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
      

      And it occurs occurs in AttributeConverterDefinition.java:67:

      entityAttributeType = (Class) attributeConverterSignature.getActualTypeArguments()[0];
      

      where the real type is ParameterizedTypeImpl, probably because Set<Category> is more complex than just Set.

        Attachments

          Activity

            People

            • Votes:
              19 Vote for this issue
              Watchers:
              25 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - Not Specified
                Not Specified
                Logged:
                Time Spent - 0.35h
                0.35h