title: Hibernate: mapping a value from another table column
body: <p>I have a domain entity looks like this:</p>
  
  <pre><code>class Exch{
      private int id;
      private String val1;
      private String val2;
  
      @Column(name = "val1")        
      public String getVal1(){
          return val1;  
      }
      @Column(name = "val2")
      public String getVal2(){
          return val2;
      }
      @Column(name = "id")
      public int id(){
          return id;
      }
  }
  </code></pre>
  
  <p>and table: </p>
  
  <p>exch</p>
  
  <hr>
  
  <p>Exch_ID| VAL1 | VAL2</p>
  
  <hr>
  
  <p>100000 |  AAA | BBB</p>
  
  <p>200000 |  CCC | DDD</p>
  
  <p>now I have another table which looks like:</p>
  
  <p>exch_extra</p>
  
  <hr>
  
  <p>Exch_ID| VAL3 | VAL4</p>
  
  <hr>
  
  <p>100000 |  ZZZ|   YYY</p>
  
  <p>200000 |  XXX|   UUU</p>
  
  <p>is there anyway I can map val3 in exch_extra table to Entity Exch without creating an extra Exch_extra entity?</p>
  
  <p>so i can have:</p>
  
  <pre><code>class Exch{
      private int id;
      private String val1;
      private String val2;
      private String val3;
  
  
      @Column(name = "val1")        
      public String getVal1(){
          return val1;  
      }
      @Column(name = "val2")
      public String getVal2(){
          return val2;
      }
      @ do something here so i can have val3 from exch_extra table
      public String val3(){
          return val3
      }
  
      @Column(name = "id")
      public int id(){
          return id;
      }
   }
  </code></pre>