[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-658) Annotation or the key word "enum" to change default behaviour to @Enumerated(value=EnumType.STRING) for all properties.

Matthew D. Frederes (JIRA) noreply at atlassian.com
Fri Jun 20 16:41:35 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30481 ] 

Matthew D. Frederes commented on ANN-658:
-----------------------------------------

We have enums with members we have to rename to be compatible with Java naming convention (cannot begin with a numeric character), but would rather our preferred name be used as the string representation in the database....  Here is a sample class

public enum EDIVersion {
    val_002000("002000"), // ASC X12 Standards Approved by ANSI in Feb, 1986
    val_002001("002001"), // Draft Standards Approved by ASC X12 in November 1987
    ...
    val_004010("004010") // Draft Standards Approved for Publication by ASC X12 Procedures Review Board through October 1997

    EDIVersion (int value) { this.value = value; }

    private final int value;
    public int value() { return value; }
}

In the above example, the database would contain "val_004010" instead of the desired "004010".

We could get this functionality using a @Type annotation, however as Michael pointed out, this has to be done on every class property where the enum type is used.  Could consideration be given to extending the annotation with a stringProperty value?

@Enumerated(value=EnumType.STRING, stringProperty = "value")

Thank you.

> Annotation or the key word "enum" to change default behaviour to @Enumerated(value=EnumType.STRING)  for all properties.
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ANN-658
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-658
>             Project: Hibernate Annotations
>          Issue Type: Sub-task
>    Affects Versions: 3.3.0.ga
>         Environment: hibernate 3.2.4.sp1; PostgresSql 8.2
>            Reporter: Michael Grünewald
>             Fix For: JPA 2.0
>
>
> Hi, what I'm  looking for is an annotation
> for the key word
> enum
> e.g.
> public enum KnownCountries {
> which changes the default behavior for this enum for every property where I used that enum as property.
> At least it would be more convenient if you can change the default and only have to change it, on properties where you don't want your own default type.
> See
> http://forum.hibernate.org/viewtopic.php?p=2363187#2363187
> for more details.
> Greetings Michael

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the hibernate-issues mailing list