I have my default schema declared in persistence.xml as:
<property name="hibernate.default_schema" value="MYSCHEMA" />
However, now I want to access one table from CURRSCHEMA which is in the same database.
Entity is created as say Currency for Curreny table in CURRSCHEMA.
But running the below query tries to access MYSCHEMA.Currency which results in error.
// here will go the code to fetch currency
String currencySql = "select C.pk.currCode from Currency C where C.pk.idCode = :idCode";
Query currencyQuery = this.em.createQuery(currencySql);
currencyQuery.setParameter("idCode", "CCY");
My entities are using annotations:
@Entity
@Table(name="CURRENCY")
public class Currency implements Serializable {
Changing @Table(name="CURRENCY") to @Table(name="CURRSCHEMA.CURRENCY") did not work.
How to go about this ?
Have you tried @Table(schema = "CURRSCHEMA", name = "CURRENCY")
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With