Ability to use parametrized type as AttributeConverter type parameter

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:

1 2 3 4 5 import javax.persistence.AttributeConverter; import javax.persistence.Converter; @Converter public class CategoryConverter implements AttributeConverter<Set<Category>, String>

But this one works:

1 2 3 4 5 import javax.persistence.AttributeConverter; import javax.persistence.Converter; @Converter public class CategoryConverter implements AttributeConverter<Set, String>

The exception is

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

And it occurs occurs in AttributeConverterDefinition.java:67:

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

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

Environment

Java SE 7, Tomcat 7.0.47, MySQL 5.6

Status

Assignee

Steve Ebersole

Reporter

A

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

4.3.5

Priority

Major