This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JPA enum mapping by explicit getId() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA enum mapping by explicit getId()" Watch "JPA enum mapping by explicit getId()" New topic
Author

JPA enum mapping by explicit getId()

manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
Hi,

for enum type you can choose EnumType.ORDINAL or EnumType.STRING. Going for string is definetely better because ordinal mandates that you never ever change the order of definition of the enum-types. On the other hand string also makes the DB entry bigger as necessary (taking the constant name, which can be quite long).

So I want to use an explicit mapping (that JPA uses getId() method).





How or is it possible with JPA to define a custom method of an java enum type?

thanks.


aldana software engineering blog & .more
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA enum mapping by explicit getId()
 
Similar Threads
Enum or int
enum
Enums in a map
"casting" an int to an enum type
enums do not allow access to static members within constructors and instance init blocks