| Lets assume a custom extended implementation of EnumType is at play here. For this example, no methods need to be overridden; just a custom type name used.
public class ExtendedEnumType extends org.hibernate.type.EnumType {
}
Then the entity definition:
@Entity(name = "CustomEntity")
@TypeDef( name = "extended_enum", typeClass = ExtendedEnumType.class )
public static class CustomEntity {
@Id
@GeneratedValue
private Integer id;
@Enumerated(EnumType.STRING)
@Audited
@Type(type = "extended_enum")
private Status status;
public enum Status {
DRAFT,
ARCHIVED
}
}
This would generate a MappingException when the HBM mapping was being sent from Envers to ORM because the the type parameters being provided by Envers to ORM were incorrect, forcing the code path to take a branch that wasn't compatible with HBM. In short the type definition was being generated something like:
<type name="org.hibernate.envers.test.integration.TypeTest$ExtendedEnumType">
<param name="org.hibernate.type.ParameterType.primaryKey">false</param>
<param name="org.hibernate.type.ParameterType.accessType">field</param>
<param name="org.hibernate.type.ParameterType.propertyName">status</param>
<param name="org.hibernate.type.ParameterType.returnedClass">org.hibernate.envers.test.integration.TypeTest$CustomEntity$Status</param>
<param name="org.hibernate.type.ParameterType.dynamic">true</param>
<param name="org.hibernate.type.ParameterType.entityClass">org.hibernate.envers.test.integration.TypeTest$CustomEntity</param>
</type>
The expected result should be
<type name="org.hibernate.envers.test.integration.TypeTest$ExtendedEnumType">
<param name="enumClass">org.hibernate.envers.test.integration.TypeTest$CustomEntity$Status</param>
<param name="useNamed">true</param>
</type>
|