title: JPA - Mapping an Entity's field to a database function result
body: <p>I'm using JPA 2.0. Is it possible to map an Entity's attribute (column) to the result of a function and then control the way it's persisted too?</p>
  
  <p>Note: This is related to PostGIS. Since there is no native support for Geometry types in JPA/EclipseLink, I might do something like this:</p>
  
  <pre><code>@Entity
  public class Foo {
  
     @Column(name="geom", appendBeforeChange( ST_FromKml ))
     public String kmlString;
  }
  </code></pre>
  
  <p>In other words, I could store the geometry as a String in Java, but when EclipseLink writes it to the database, it should first call the database function ST_FromKml and provide the String, which will convert it to the Geometry type in the database...</p>
  
  <p>I know it's a stretch, but figured I would ask...</p>