title: @formula to fetch an entity object
body: <p>I wan to fetch an object of entity using formula annotation</p>
  
  <pre><code>@Formula(value="(select ar from article ar where ar.id=1)")
  private Article article;
  </code></pre>
  
  <p>Tried lot's of way. Pls help</p>
  
  <blockquote>
    <p>Exception in thread "main" org.hibernate.MappingException: Could not determine type for: com.test.bean.Article, at table: Menu, for columns: [org.hibernate.mapping.Formula( (select ar from article ar where ar.id=1) )]</p>
  </blockquote>
  
  <p>exception seems to say that it's not able to resolve type</p>
  
  <p>Updating Entities</p>
  
  <pre><code>   @Entity
      public class Menu {
  
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          private Integer id;
  
          // @Formula(value="article.id=1")
          // @JoinColumnOrFormula(formula=@JoinFormula("(select ar from article ar where ar.id=1)"),column=@JoinColumn(insertable=false,updatable=false))
          // @Transient 
          // @OneToOne(fetch=FetchType.EAGER,targetEntity=Article.class)
          // @JoinColumn(insertable=false,updatable=false,columnDefinition="(select ar from article ar where ar.id=1)")
          @Formula(value = "(SELECT ar.id from article ar where ar.id=1)")
  //      @OneToOne(targetEntity=Article.class,fetch=FetchType.EAGER)
  //      @Fetch(FetchMode.SELECT)
          private Article article;
  
          @Formula(value = "(SELECT count(*) from article ar where ar.id=1)")
          private Integer count;
  
  
          public Integer getId() {
              return id;
          }
  
          public void setId(Integer id) {
              this.id = id;
          }
  
          public Article getArticle() {
              return article;
          }
  
          public void setArticle(Article article) {
              this.article = article;
          }
  
          public Integer getCount() {
              return count;
          }
  
          public void setCount(Integer count) {
              this.count = count;
          }
  
          @Override
          public String toString() {
              return "Menu [id=" + id + ", article=" + article + ", count=" + count
                      + "]";
          }
  
      }
  
  
      @Entity(name = "article")
      public class Article {
  
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          private Integer id;
  
          private String uid;
  
          private String content;
  
          public Integer getId() {
              return id;
          }
  
          public void setId(Integer id) {
              this.id = id;
          }
  
          public String getUid() {
              return uid;
          }
  
          public void setUid(String uid) {
              this.uid = uid;
          }
  
          public String getContent() {
              return content;
          }
  
          public void setContent(String content) {
              this.content = content;
          }
  
          @Override
          public String toString() {
              return "Article [id=" + id + ", uid=" + uid + ", content=" + content
                      + "]";
          }
  
      }
  </code></pre>
  
  <p>cfg also contain mapping.</p>