Hello Armin,
how do I get the information from my repository file into the
prodRepository object in your example?
MM.addProfile("production", prodRepository)
^^^^^^^^^^^^^^^^
Regards
Lasse
___
|---------+--------------------------->
| | "Armin Waibel" |
| | <[EMAIL PROTECTED]|
| | ait.de> |
| | |
| | 16.09.03 18:16 |
| | Bitte antworten |
| | an "OJB Users |
| | List" |
| | |
|---------+--------------------------->
>-------------------------------------------------------------------------------------------------------------------------------|
|
|
| An: "OJB Users List" <[EMAIL PROTECTED]>
|
| Kopie:
|
| Thema: Re: Antwort: RE: Using different Qualifiers in DB2
|
>-------------------------------------------------------------------------------------------------------------------------------|
Hi Lasse,
Don't know if I understand your problem, but I will explain
what I mean.
Currently it's only possible to switch between different
DescriptorRepository (metadata class-descriptor container)
instances on a per thread based way using 'profiles' managed by
MetadataManager (MM). See MM javadoc.
In the 'normal' repository.xml only declare connection
specific stuff (jdbc-connection-descriptors, by default in
repository_database.xml sub-file).
Then create additional repository files without connection
metadata. Say all production relevant class-descriptors are declared
in
'production.xml' file (with several sub-files if needed). Then create
another repository file 'test.xml' and declare all TEST
class-descriptor.
With MetadataManager it is now possible to load/read these
repository at runtime (before the first call to
PersistenceBrokerFactory
[PBF] is made) and add these as profiles
MM.addProfile("production", prodRepository)
MM.addProfile("test", testRepository)
(you can set one of these DescriptorRepository instances as
global repository - see MM javadoc).
Now it is possible to load a dedicated profile using
MM.loadProfile("test")
for the calling thread at runtime before ask the PBF for
a PersistenceBroker instance.
Pitfall: be careful with caching, e.g. only use
ObjectCachePerBrokerImpl
Would this help you?
regards,
Armin
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, September 16, 2003 5:04 PM
Subject: Antwort: RE: Using different Qualifiers in DB2
>
> Hello,
>
> whoops, that was a copying error, the classes are named different,
I
> just added a second class-descriptor to make the example clearer.
>
> What I meant: PRODUCTION.USER and TEST.USER
> I want to switch the PRODUCTION to TEST and vice versa during
> runtime.
> Here is the correct XML:
>
> <class-descriptor class="User" table="PRODUCTION.USER">
> .........
> </class-descriptor>
> <class-descriptor class="Order" table="PRODUCTION.ORDER">
> .........
> </class-descriptor>
>
> and the second XML is
>
> <class-descriptor class="User" table="TEST.USER">
> .........
> </class-descriptor>
> <class-descriptor class="Order" table="TEST.ORDER">
> .........
> </class-descriptor>
>
> Lasse
>
>
>
>
>
> |---------+--------------------------->
> | | [EMAIL PROTECTED]|
> | | de |
> | | |
> | | 16.09.03 16:48 |
> | | Bitte antworten |
> | | an "OJB Users |
> | | List" |
> | | |
> |---------+--------------------------->
>
>
-----------------------------------------------------------------------
--------------------------------------------------------|
> |
|
> | An: [EMAIL PROTECTED]
|
> | Kopie:
|
> | Thema: RE: Using different Qualifiers in DB2
|
>
>
-----------------------------------------------------------------------
--------------------------------------------------------|
>
>
>
> Hello Lasse,
>
> > -----Original Message-----
> >
> > <class-descriptor class="User" table="PRODUCTION.USER">
> > .........
> > </class-descriptor>
> > <class-descriptor class="User" table="PRODUCTION.ORDER">
> ^^^^
> I suppose you mean 'Order' here?
>
> > .........
> > </class-descriptor>
> >
> > and
> >
> > <class-descriptor class="User" table="TEST.USER">
> > .........
> > </class-descriptor>
> > <class-descriptor class="User" table="TEST.ORDER">
> ^^^^
> ditto.
>
> > .........
> > </class-descriptor>
>
> >
> > - The qualifier depends on what the user has choosen at the login
> of
> > our application
> > - It's a webbased application
> >
> > Is there a way I can set the qualifier at runtime in order to
> switch
> > between them?
>
> Something like (untested)
>
> mdm = org.apache.ojb.broker.metadata.MetadataManager.getInstance();
> dr = mdm.getDescriptorRepository();
> cld = dr.getDescriptorFor(User.class);
> cld.setTableName("TEST.USER");
>
> might work. Given that in your application several users access
the
> database with different qualifiers, you may have to switch back and
> forth and care abot multithreading. I do not know what happens
then,
> maybe someone else can help.
>
> Olli
>
>
---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]