These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem accessing Synonyms in hibernate....
PostPosted: Sat Jan 23, 2010 4:09 pm 
Newbie

Joined: Mon Aug 04, 2008 2:35 pm
Posts: 4
Location: Texas
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.