Hi David,
----- Original Message -----
From: "David C. Hicks" <[EMAIL PROTECTED]>
To: "OJB" <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2003 8:54 PM
Subject: Multiple Databases in one repository.xml?
> From reading through the OJB documentation on repository.xml, I get
the
> impression that it is possible to have connection pools to two
different
> data sources in the same application, however I don't see any way to
map
> which objects are persisted in which data source.
Say you have defined two different jdbc-connection-descriptor
using different datasources with jcd-alias names 'db_1' and 'db_2'.
PBKey key1 = new PBKey("db_1", "user1", "passwd1");
PBKey key2 = new PBKey("db_2", "user2", "passwd2");
PersistenceBroker broker_1 = PBF.createPersistenceBroker(key1);
PersistenceBroker broker_2 = PBF.createPersistenceBroker(key2);
Or is the problem that you get an object of type XY and
you want automatic decide which datasource/broker is
to use?
If so you can use custom-attributes in class-descriptor
tag (of the persistent object metadata):
<attribute
attribute-name="datasource"
attribute-value="db_1"/>
read with
classdescriptor.getAttribute("datasource")
To get the ClassDescriptor of the given object
you can use MetadataManager.
regards,
Armin
> Has anyone ever tried
> this? I actually do have a need to do this as I have a component that
> utilizes OJB for persistence that will be embedded in several
> applications. One of these applications also uses OJB for
persistence,
> but all applications need to share a common database for my component.
>
> Thanks in advance for any input,
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]