title: Ways to save enums in database
body: <p>What is the best way to save enums into a database?</p>
  <p>I know Java provides <code>name()</code> and <code>valueOf()</code> methods to convert enum values into a String and back. But are there any other (flexible) options to store these values?</p>
  <p>Is there a smart way to make enums into unique numbers (<code>ordinal()</code> is not safe to use)?</p>
  <h4>Update</h4>
  <p>Thanks for all awesome and fast answers! It was as I suspected.</p>
  <p>However, a note to <a href="https://stackoverflow.com/users/3295">toolkit</a>: That is one way. The problem is that I would have to add the same methods to each enum type that I create. That's a lot of duplicated code and, at the moment, Java does not support any solutions for this (a Java enum cannot extend other classes).</p>