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: Map entities from different databases
PostPosted: Tue Jun 21, 2011 3:53 pm 
Newbie

Joined: Mon Jul 21, 2008 3:15 pm
Posts: 7
Hi

Sorry if this is really easily answered but I've got my head in a spin....

I've two classes.

- Person
- Address

Person has a ManyToOne relation with Address.

Is it possible to have Person pointing to one database and Address to a complete different one, in H3?

And if so... is it possible too for both classes to be in differents JAR files? each one with its own persistence.xml file?


Top
 Profile  
 
 Post subject: Re: Map entities from different databases
PostPosted: Tue Jul 05, 2011 8:47 am 
Newbie

Joined: Mon Jul 21, 2008 3:15 pm
Posts: 7
Please I really need help with this...


Top
 Profile  
 
 Post subject: Re: Map entities from different databases
PostPosted: Mon Jul 11, 2011 8:22 am 
Newbie

Joined: Mon Jul 21, 2008 3:15 pm
Posts: 7
This is not exactly what I'm looking for.

Let's say I've an entity Person.

[code]Person
-------
private Integer id
private String name

It's not written by me and is built in common-entities.jar.

That file has it's own persistence.xml, pointing to an oracle database.



Now I'm building my own project, wich references "common-entities.jar" and I have the entity Employee.
This project points to a MySQL database.

[code]

public class Employee {

private Integer id
private String jobDescription

@OneToMany(cascade={CascadeType.All}, fetch=FetchType.EAGER)
private Person person

[/code]

So a write a form to update Employee and enable it to change the "name" property of Person.

What I want to know is if Hibernate can tranparently treat this relation even if both entities point to diferent database.


Top
 Profile  
 
 Post subject: Re: Map entities from different databases
PostPosted: Tue Jul 12, 2011 5:18 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
Hibernate cannot do that. It would have to dig deeply into each database's transaction engine to get a two-phase commit working, and that's simply outside of Hibernate's scope.

However, I think there are solutions outside Hibernate itself.
One way would be to check if your database offers a way to include tables from external databases (possibly even from a different vendor) in their catalog. For example, Oracle has a "database link" feature that does that.
I dimly remember that I stumbled upon some middleware that does similar things when I was researching connection pooling modules. It was one of those four-letter acronyms that I keep forgetting, so maybe somebody else can pick up.


Top
 Profile  
 
 Post subject: Re: Map entities from different databases
PostPosted: Tue Jul 12, 2011 5:18 pm 
Newbie

Joined: Mon Jul 21, 2008 3:15 pm
Posts: 7
Ok. Thanx!


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.