Hi Armin,

your suggestion might work for my problem. I'll try it.
At which point will the different class defs (that I added via
MM.addProfile) be loaded? All in "advance" or not until I'm doing a
concrete MM.loadProfile(...) call. The reason why I ask this is that
my class defs are about 650 kb in size for each qualifier. It takes
some seconds for OJB to get ready for "business". And if that happens
every time I want to switch the qualifier...especially because it's a
web app where all the users use the same server.

But just to be sure you know what I mean: Can I extend the table name
at runtime? In this case I would just define the Table as USER and
PRODUCTION (in the repository) without the qualifier and add the
right qualifier (PRODUCTION or TEST) at runtime before I'm doing a
query/insert/.... So OJB plugs it together to PRODUCTION.USER and
PRODUCTION.TEST. Is that possible?

<class-descriptor class="User" table="USER">
.........
</class-descriptor>
<class-descriptor class="Order" table="ORDER">
.........
</class-descriptor>

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]

Reply via email to