Hi there,
probably the Subject was not clear, so I'm going to try to explain what is the situation.
I'm developing a system (jsp, servlets, jpa, hibernate; no struts, spring or jsf) that has two diferent databases related to.
What I'm wondering is if there is a way to properly map classes from these two databases in one class.
Since I guess this still is not a good explanation I'll try to give an example.
Code:
public class Person {
... id and other stuff ...
@OneToOne // from one database
private Address address;
@OneToOne // from another database
private Telephone telephone;
// getters and setters...
}
In this very moment what I do is to map address on the normal way (since person and address are in the same base) and the telephone I'm just taking the id from the other database to save on this object. And when I retrieve a Person instance I explicit make a query on the other database to bring the telephone object itself.
Well, of course my domain is not Person, Telephone and Address in two diferent databases, but that's what came in mind to explain the situation.
The problem with my approach is that decreases considerably the performance when I try to filter by the telephone...
Does anyone have a tip for me?
Thanks in advance.
Bruno Krebs