-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Custom Enum ordinal and field mapping
PostPosted: Tue Jan 22, 2008 4:15 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 11:11 am
Posts: 22
Is it possible to add filed to Enum and use it instead of the ordinal?
Example:
Code:
public enum RuleType {
      FIRST_RULE(10),
      SECOND_RULE(20);

int myFiled;
RuleType(int i){
   myFiled=i;
}
}


So I can use myFiled with the ruleType filed ?
Code:

@Enumerated(EnumType.ORDINAL)
@Column(name="RULE_TYPE")
public RuleType getRuleType() {
   return ruleType;
}


Top
 Profile  
 
 Post subject: Re: Custom Enum ordinal and field mapping
PostPosted: Mon Feb 21, 2011 3:55 pm 
Newbie

Joined: Fri Dec 02, 2005 8:03 am
Posts: 10
I was looking for something like this and it seems that writing a user type is still the only way to go. I was hopping that by now we would have a more elegant solution for a so common use case.

Using ordinal values is very brittle and using String most of the times is not possible with legacy databases.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.