title: JPA: Map invalid database values to enums
body: <p>In my datamodel a have many entities where attributes are mapped to enumerations like this:</p>
  
  
  
  <pre><code>@Enumerated(EnumType.STRING)
  private MySpecialEnum enumValue;
  </code></pre>
  
  <p>MySpecialEnum defines some fixed values. The mapping works fine and if the database holds a NULL-value for a column I get NULL in the enumValue-attribute too.
  The problem is, that my backend module (where I have no influence on) uses spaces in CHAR-columns to identify that no value is set. So I get an IllegalArgumentException instead of a NULL-value.</p>
  
  <p>So my question is: Is there a JPA-Event where I can change the value read from the database before mapping to the enum-attribute?
  For the write-access there is the @PrePersist where I can change Null-values to spaces. I know there is the @PostLoad-event, but this is handled after mapping.</p>
  
  <p>Btw: I am using OpenJpa shipped within WebSphere Application Server.</p>