JPA: dynamically mapping an Entity to a table based on an instance variable
<p>Here is the problem i have:</p>

<pre><code>class CurrencyPrice {
    @Transient
    String pair;
    float spotPrice;
    Date timeStamp;
}
</code></pre>

<p>And I have 3 table the names of which stand for "usd value of euro/gbp/yen respectively": usd_euro, usd_gbp &amp; usd_yen. They all have the same 3 columns: id, spotprice, timestamp. </p>

<p>For some reason i cannot have a single table. The transient instance variable 'pair' will have the following values depending on what it represents: "usd_euro", "usd_gbp" &amp; "usd_yen"</p>

<ol>
<li><p>And depending on the value in 'pair' I want to insert a row in one of the tables, eg: if I have the value "usd_yen" in 'pair' then the object should be persisted in usd_yen table. </p></li>
<li><p>And when I want to fetch data, I want JPA to decide which table to SELECT from based on the value in 'pair'</p></li>
</ol>

<p>This is simple in JDBC but is there a way to do this in JPA? </p>

<p>Thank you.</p>