I have table MV_ULICE in schema ADRESY. However in JPA I connect to database (Oracle) using different user then ADRESY. This user has privilege to access tables from schema ADRESY, so in JPA there was no problem with defining entities, since you can easily provide different schema in entity definition:
@Entity
@Table(name = "MV_ULICE", schema = "ADRESY")
public class PoiStreet {
...
The problem started when I wanted to create Native Query using JPA. Query looks like this:
final String queryString = "SELECT * "
+ "FROM MV_ULICE streets "
+ "WHERE CONNECT_BY_ISLEAF = 1 AND streets.status != 'H' "
+ "CONNECT BY NOCYCLE PRIOR streets.sym_ul = streets.symulold "
+ "START WITH streets.sym_ul = 'ulica'";
Query query = getEntityManager().createNativeQuery(
queryString, poi.domain.entities.streets.PoiStreet.class);
And this does not work. I simply get exception form Oracle "Table or view does not exist".
I tried chanign MV_ULICE to ADRESY.MV_ULICE
final String queryString = "SELECT * "
+ "FROM ADRESY.MV_ULICE streets " + ...
but that did not help.
So does anyone has experience with native queries on oracle with different schemas then user that is accessing the database? Please help :)