• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPA enum mapping by explicit getId()

 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!