[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7108) @TypeDef doesn't work for enums

Gail Badner (JIRA) noreply at atlassian.com
Wed Feb 29 19:52:48 EST 2012


    [ https://hibernate.onjira.com/browse/HHH-7108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45763#comment-45763 ] 

Gail Badner commented on HHH-7108:
----------------------------------

Please create a pull request from your fork of the hibernate-orm repository (https://github.com/hibernate/hibernate-orm). Please include your fix and a test case that reproduces your issue in the pull request.

Thanks,
Gail 

> @TypeDef doesn't work for enums
> -------------------------------
>
>                 Key: HHH-7108
>                 URL: https://hibernate.onjira.com/browse/HHH-7108
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.1.0
>         Environment: hibernate-jpa-2.0-api:1.0.1-Final; hibernate-core:4.1.0.Final; hibernate-entitymanager:4.1.0.Final 
>            Reporter: Michael Nascimento Santos
>            Priority: Critical
>              Labels: annotations, hibernate, jpa2, typedef
>
> @TypeDef is supposed to allow users to define standard types to be used for specific classes. However, due to a bug in implementation, it simply doesn't work for enums.
> Enums are implicitly handled by the JPA spec. However, if a @TypeDef is defined for a particular enum, it will never be picked up due to bug in org.hibernate.cfg.annotations.SimpleValueBinder .
> This class has a concept of a "explicitType", i.e., a type that was explicitly specified for a property. However, even if @EnumType is not used to annotate a property, method setType(XProperty,XClass) considers the property as annotated with it. Then, when fillSimpleValue() is called as part of second-pass compilation, the ternary in line 344 chooses org.hibernate.type.EnumType instead of the enum FQN, causing any @TypeDef to be ignored.
> This behaviour should be fixed by considering a non-annotated enum property as implicitly typed, not explicitly. Then, the resolution order should be changed to explicitType -> returnedClassName -> implicitType. This would preserve default, expected behaviour for regular enums, while allowing @TypeDef to be used for enums as well.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list