title: Hibernate with JPA ignoring @Formula
body: <p>I have a <code>Formula</code> defined as:</p>
  
  <pre><code>@Entity
  @Table(name = "MyEntity")
  @org.hibernate.annotations.Table(appliesTo = "MyEntity")
  public class MyEntity
  {
      @Enumerated(value = javax.persistence.EnumType.STRING)
      @Transient
      @Formula(value = "select e.state from OTHER_ENTITY e")
      private State state;
  
      public State getState()
      {
          return this.state;
      }
  //setter and another properties
  }
  </code></pre>
  
  <p>But it is ignoring it.</p>
  
  <p>Here is my <code>Persistence Unit</code>:</p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0"&gt;
  &lt;persistence-unit name="myPersistence" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;mapping-file&gt;META-INF/orm.xml&lt;/mapping-file&gt;
      &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /&gt;
          &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="hibernate.connection.url" value="jdbc:mysql://url:3306/db" /&gt;
          &lt;property name="hibernate.connection.username" value="root" /&gt;
          &lt;property name="hibernate.connection.password" value="root" /&gt;
          &lt;property name="hibernate.show_sql" value="true" /&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="validate" /&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>The sql are generated without the <code>Formula</code>.</p>
  
  <p>If I remove the <code>@Transient</code> the <code>JPA</code> tries to load the <code>state</code> column and then fails.</p>
  
  <p>I want to calculate the state based on the state of another entity. That's why the I think a <code>Formula</code> works.</p>
  
  <p>Thank you!</p>
  
  <p>Udo.</p>