Ajitesh Das wrote:
Hi Thomas:Think Thomas mean that you should use custom attribute element in class-descriptor:
Thanks for your reply. I have checked the DTD of repository xml, but could not find out the way
to add "a key pointing to the associated ConnectionDescriptor in each
ClassDescriptor".
There is no such element or attribute.
Can you give me an example of that?
<class-descriptor
class="org.apache.ojb.broker.ComplexReferenceTest$TeamMember"
table="CRT_MEMBER"
><attribute attribute-name="DB_NAME" attribute-value="myJcdAlias"/>
<field-descriptor
name="id"
column="ROLE_ID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
...Then you can lookup the attribute and do something like
Object obj = ...
ClassDescriptor cld = MetadataManager.getInstance().getClassDescriptor(obj.getClass());
String db = cld.getAttribute("DB_NAME");
PersistenceBroker broker = PBF.createPersistenceBroker(new PBKey(db));
...
You said in your mail that you have different repository files to load - more info how to load different object metadata please see javadoc for MetadataManager.
regards, Armin
Thanks and regards Ajitesh
-----Original Message-----
From: Thomas Mahler [mailto:[EMAIL PROTECTED] Sent: Saturday, January 17, 2004 2:57 AM
To: OJB Users List
Subject: Re: Repository XML limitation and design question.
Hello Ajitesh,
Case A works without any problems. You simply define a set of ConnectionDescriptors and a set of ClassDescriptors in the Repository.
In each ClassDescriptor you have a key pointing to the associated ConnectionDescriptor.
Case B works too, but needs some consideration. At a given point in a time given class is associated with exactly one connectionDescriptor.
SO if you want to have a class mapped to several Connections you can do this only sequentially!
So you you have to simply change the assigned ConnectionDescriptor key of the ClassDescriptor at runtime. This is done through the Metadata
API.
cheers, Thomas
Ajitesh Das wrote:
To all OJB gurus:
First of all this may not be a limitation on OJB what I have wrote
as
subject but it seems that there is no easy way to handle this.
Here is my problem :
I like to write a repository XML file [ please note a single
repository
file for each case] which captures the following conditions :
I have a set of Databases/data sources = { Da, Db , Dc, ...., Dn }
And I have a set of class-descrptors =
{ { a1, a2, a3 ....,ax},
{b1, b2, b3, ....,by},
:::::::::::::::::::
{n1, n2, n3, ....,nz}}
I want to map ->
Class Descriptors ->{ a1,a2,::::,ax} to be mapped to [Da]
{ b1,b2,::::,by} to be mapped to [Db]
{ c1,c2,::::,cw} to be mapped to [Dc]
:::::::::::::::::::::::::::
{ n1,n2,::::,nx} to be mapped to [Dn]
Case A:
Set (a)i and Set (b)j are disjoint.
That is: any ai != bj where i= 1,2...x
And j= 1,2,...y
Case B:
Set (a)i and Set (b)j are intersect each other.
That is: may be ai == bj where i= 1,2...x
And j= 1,2,...y
Has anybody did this before?
If this can not be done in a single repository xml ...is there any way it can be worked around?
Thanks
Ajitesh
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
