Hi friends,
I have Database1,Database2 in Oracle 11g. Most of the time i will be using Database1. Sometime i need to access Table1 in Database2. I have created a DBLink1 in Database1 on Schema1 to access a Table1 in Database2. and i have created a Synonym called Synonym1_Table1 using DBLink1 in Database1 on Schema1 to access a Table1 in Database2.
I am using Hibernate with JPA. When i try to access Synonym1_Table1, Hibernate raises exception saying "GenericJBDBException : Could not execute Query".
I tried to access Synonym1_Table1 through DBArtisan, Toad. It returns the data.
Then i created a view1_Table1 using the DBLink1 ( To check whether i could access view using this dblink in hibernate ). Still i am getting same error.
I could access any view or table in the same schema in hibernate without using DBLink.
Can anyone help me how to use Synonyms in Hibernate. I am working on some high priority issue, this stuff blocking me to proceed further. Any help is highly appreciated.
My Entity Class looks like this Code:
@NamedQueries( { @NamedQuery(name = "findAllSynonym1_Table1",
query = "select synonym1_Table1 from Synonym1_Table1 as synonym1_Table1") })
@Entity
@Table(name = "Synonym1_Table1" , schema = "Schema1")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class Synonym1_Table1 extends BaseDomain {
............
...........
.........
}
and my DAO code to execute this query is Code:
try {
Query query = em.createNamedQuery("findAllSynonym1_Table1");
query.setHint("org.hibernate.cacheable", "true");
resultList = query.getResultList();
} catch (RuntimeException e) {
logger
.error("Throwing Runtime Exception while trying to fetch All Synonym1_Table1: "
+ e.getMessage());
throw new WamDaoException(e.getMessage());
} finally {
this.closeEntityManager();
}
Thanks in advance.
Siva.