-->
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.  [ 5 posts ] 
Author Message
 Post subject: Oracle Database Link
PostPosted: Fri Feb 06, 2009 7:05 am 
Newbie

Joined: Mon Sep 01, 2008 9:38 am
Posts: 3
Hello

I use Hibernate and Spring. In the past I only worked with 1 database. Now I have to combine 2 databases, so I created a Database Link in Oracle, called 'LINK_CIB'.

When I execute the query "select * from entiteit@LINK_CIB" in Oracle SQL Developer, I get all the rows in the table entiteit.

I also want to use this link in my application, so I tried this:

getHibernateTemplate().findByNamedParam("from Entiteit@LINK_CIB where cibNr_ID=:cibNr_ID","cibNr_ID",cibNr_ID);

and the class Entiteit

@Entity
@Table(name="entiteit@LINK_CIB")
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class Entiteit {
...
}


but I get the error unexpected char: '@' [from Entiteit@LINK_CIB where cibNr_ID=:cibNr_ID]

Can someone help me with this problem?
barbara


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 7:13 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
I think you should be using "from Entiteit where cibNr_ID=:cibNr_ID" instead of "from Entiteit@LINK_CIB where cibNr_ID=:cibNr_ID"

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 7:16 am 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
Try setting up a view onto the remote table instead.


--
Stephen Souness


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 8:36 am 
Newbie

Joined: Mon Sep 01, 2008 9:38 am
Posts: 3
Thanks Sounie!

I created the view Entiteit 'SELECT * FROM Entiteit@LINK_CIB' and referred in my code to Entiteit and it works!

barbara


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 11:15 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
barbarab wrote:
I created the view Entiteit 'SELECT * FROM Entiteit@LINK_CIB' and referred in my code to Entiteit and it works!


Another option would be to create synonyms to the remote tables in the Oracle schema. e.g. CREATE SYNONYM ENTITEIT FOR ENTITEIT@LINK_CIB;

_________________
Maury


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

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.