You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by ss...@intermediate.de on 2002/12/23 14:54:48 UTC

Using mutliple Databases simultaneously with OJB ?

Hi,

I would like to know what possibilties exist for using OJB with
multiple databases at the same time?

Can I store one object in one DB and another in another DB?

Do I have to instantiate 2 brokers and feed them different config files?

Can I store parts of an object in one DB and other parts in another? If so,
how do I
then build the complete object during lookup?

Background is that we have an ERP database and our own extra database which
enriches the ERP database with extra data.

Thanks for any suggestions and merry Xmas,
   Stefan





[FAQ]: Using mutliple Databases simultaneously with OJB ?

Posted by Thomas Mahler <th...@apache.org>.
Hi again Stefan,

sschloesser@intermediate.de wrote:
> Hi,
> 
> I would like to know what possibilties exist for using OJB with
> multiple databases at the same time?

currently you can only have one jdbc-connection-descriptor per repository.

In order to work against multiple databases you just have to use 
different broker bound against different repositories.

There is a sample repositoryFarAway.xml and respective testcases showing 
how to do this.

In the near future working with multiple DBs will become even easier by 
allowing multiple jdbc-connection-descriptor per repository.

> Can I store one object in one DB and another in another DB?
> 

Yes, please refer to the "faraway" samples.

> Do I have to instantiate 2 brokers and feed them different config files?

correct!

> Can I store parts of an object in one DB and other parts in another? If so,
> how do I
> then build the complete object during lookup?

Say you have databases A and B. You also have two classes ClassA (mapped 
to A) and ClassB (mapped to B).

ClassA holds a reference to a ClassB object.

now follow these steps:
1. obtain two broker instances brokerA and brokerB working against the A 
and B database respectively.

2. call
ClassA a = (ClassA) brokerA.getObjectByQuery(...);

to load the instance a. To avoid automatic (and in this case wrong) 
retrieval of the ClassB reference the respective reference-descriptor 
must be set to auto-retrieve="false"

3. call
brokerB.retrieveAllReferences(a);
to use the brokerB to retrieve the ClassB reference explicitely.


cheers,
Thomas


> Background is that we have an ERP database and our own extra database which
> enriches the ERP database with extra data.
> 
> Thanks for any suggestions and merry Xmas,
>    Stefan
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 
>