-->
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.  [ 9 posts ] 
Author Message
 Post subject: Oracle DBLink
PostPosted: Mon Oct 25, 2004 1:02 pm 
Newbie

Joined: Mon Oct 25, 2004 12:53 pm
Posts: 9
Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Hi All,

Dose anybody know how to work with Oracle DBLink with HQL and Hibernate, or dose Hibernate support Oracle DBLink (yet)?

Thanks a lot!
John


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
As in "CREATE DBLINK"? Sure, that is exposed transparently through Oracle's jdbc driver; just make sure your schema owner is the DBLINK owner (or use an appropriate SYNONYM).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 10:19 am 
Newbie

Joined: Mon Oct 25, 2004 12:53 pm
Posts: 9
Thank you Steve!

I am asking our DBA to 'merge' the dblink_schema to be the same as my_schema, so I can query something like select * from my_schema.abc@dblink.

If DBlink is transparent, I do not need to map my table as:
<class name="Abc" table="Abc@dblink"> in abc.hbm.xml file, correct?

Before I can test, I have Parent/Child relationship from my_schema.ParentTable to dblink_schema.ChildTable, if I set up the relationship mapping in hbm.xmls, can Hibernate take care of them in cascade-insert/delete etc. (within one session)?

Thank a lot.
John
jzhao@amfm.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 12:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No you would need to use the tablename@dblinkname syntax.

The best way is to use the SYNONYM approach. Just create a SYNONYM named 'tablename' (under the schema owner) for 'tablename@dblinkname'. Then you do not need to reference it using the '@' syntax.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 1:17 pm 
Newbie

Joined: Mon Oct 25, 2004 12:53 pm
Posts: 9
Thank you Steve!

My DBA is not willing to go the SYNONYM approach, since there will be too many objects to maintain. If we still have other syntex issues, I will try to push this approach again.

My second question from last email, if DBlink is totally transparent, then session/transaction (2PC maybe)/RI for the two data sources can be handled by Hibernate just like in one (unified) data source??

Thanks,
John


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
if DBlink is totally transparent, then session/transaction (2PC maybe)/RI for the two data sources can be handled by Hibernate just like in one (unified) data source

Absolutely. This is a really great thing in Oracle. Essentially the oracle engine takes over resposibility for coordinating transactions between the two schemas (relative to the explicit transactions). I have never tried, but as far as I understand RI can also be defined across a DBLINK.

The CREATE SYNONYM command is painfully easy (CREATE SYNONYM synonymname FOR actualobjectname)... Don't quite understand the objection here; we used these quite extensively at my last job with blessings from three very good Oracle DBAs.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 1:52 pm 
Newbie

Joined: Mon Oct 25, 2004 12:53 pm
Posts: 9
Steve,

Can we say that DBLink is an effective strategy to deal with transactions with multiple data sources?

John


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 2:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
AFAIKL, yes. I'd certainly want to ask my DBA how well Oracle handles transactions across DBLINKs; I would guess it handles it great, but I'm not an Oracle DBA...

Also, if you do a lot of joining/subquerying across DBLINKs, keep in mind that in my experience Oracle tends to have a hard time coming up with optimal execution plans. Specifically, remember the "DRIVING_SITE" query hint as sometimes that is the only remedy for badly performing queries involving DBLINKs...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 2:07 pm 
Newbie

Joined: Mon Oct 25, 2004 12:53 pm
Posts: 9
Thanks a lot Steve, Hibernate is great so are you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.