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 Marc Tinnemeyer <ma...@gmx.net> on 2004/12/09 11:28:27 UTC

switching between databases

hi everybody,

i got a question concerning ojb.

i have several applications (multiple customers) using different
databases. the databases all share the same structure, so my idea is to
create a global application the customers can use to perfrom some
administrative actions.

that app will be globally installed (so it can be easily maintained)
and is then mapped to the correct uris where it can be reached e.g.
through: 

https://abc.com/admin 
and 
https://def.com/admin

and now i'd like to know if it is possible to definie multiple databases
in ojb (in repository_database.xml) that can be switched depending on
the url that is called ?

there will be a mapping like:

abc.com -> db1
def.com -> db2

is this possible ?

big thanks in advance

Marc Tinnemeyer

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: switching between databases

Posted by Marc Tinnemeyer <ma...@gmx.net>.
thank you both for your comments and suggestions,

i guess i'll stick to armin's 2nd suggestion.
is there already a release plan or s.th. for 1.1 ?

kind regards,

marc



On Thu, 09 Dec 2004 16:10:30 +0100
Armin Waibel <ar...@apache.org> wrote:

> Hi Marc,
> 
> as Daniel said, shouldn't be a problem. Only thing you have to take
> care of is caching. You can't use the default cache implementation
> with default settings - ObjectCacheDefaultImpl. Because each DB needs
> it's own cache section for the used persistent objects (with shared
> class model).
> 
> You have two possibilities:
> 1. use ObjectCachePerBrokerImpl, does only cache objects on 
> PersistenceBroker level till you close the used PB instance.
> 2. use the default cache ObjectCacheDefaultImpl and set the property 
> 'cachingKeyType' to 1. This will separate caching for each DB.
> 
> More info see
> http://db.apache.org/ojb/docu/guides/objectcache.html
> and
> http://db.apache.org/ojb/api/org/apache/ojb/broker/cache/ObjectCacheDefaultImpl.html
> 
> The upcoming OJB 1.1 will be able to handle all kind of caches in a
> more sophisticated manner, so don't worry ;-)
> 
> regards,
> Armin
> 
> Daniel Perry wrote:
> 
> > No problem...
> > 
> > Instead of doing:
> > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> > 
> > Use
> > broker = PersistenceBrokerFactory.createPersistenceBroker(new
> > PBKey("jcdAlias"));
> > Where jcdAlias is the alias you gave the connection in
> > repository_database.xml.
> > 
> > I'm pretty sure you can do it using the other APIs aswell, just
> > never tried myself.
> > 
> > Daniel.
> > 
> > 
> > 
> >>-----Original Message-----
> >>From: Marc Tinnemeyer [mailto:marc-web@gmx.net]
> >>Sent: 09 December 2004 10:28
> >>To: ojb-user@db.apache.org
> >>Subject: switching between databases
> >>
> >>
> >>hi everybody,
> >>
> >>i got a question concerning ojb.
> >>
> >>i have several applications (multiple customers) using different
> >>databases. the databases all share the same structure, so my idea is
> >to>create a global application the customers can use to perfrom some
> >>administrative actions.
> >>
> >>that app will be globally installed (so it can be easily maintained)
> >>and is then mapped to the correct uris where it can be reached e.g.
> >>through:
> >>
> >>https://abc.com/admin
> >>and
> >>https://def.com/admin
> >>
> >>and now i'd like to know if it is possible to definie multiple
> >databases>in ojb (in repository_database.xml) that can be switched
> >depending on>the url that is called ?
> >>
> >>there will be a mapping like:
> >>
> >>abc.com -> db1
> >>def.com -> db2
> >>
> >>is this possible ?
> >>
> >>big thanks in advance
> >>
> >>Marc Tinnemeyer
> >>
> >>-------------------------------------------------------------------
> >-->To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> > 
> > 
> > 
> > -------------------------------------------------------------------
> > -- To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> > 
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: switching between databases

Posted by Armin Waibel <ar...@apache.org>.
Hi Marc,

as Daniel said, shouldn't be a problem. Only thing you have to take care 
of is caching. You can't use the default cache implementation with 
default settings - ObjectCacheDefaultImpl. Because each DB needs it's 
own cache section for the used persistent objects (with shared class model).

You have two possibilities:
1. use ObjectCachePerBrokerImpl, does only cache objects on 
PersistenceBroker level till you close the used PB instance.
2. use the default cache ObjectCacheDefaultImpl and set the property 
'cachingKeyType' to 1. This will separate caching for each DB.

More info see
http://db.apache.org/ojb/docu/guides/objectcache.html
and
http://db.apache.org/ojb/api/org/apache/ojb/broker/cache/ObjectCacheDefaultImpl.html

The upcoming OJB 1.1 will be able to handle all kind of caches in a more 
sophisticated manner, so don't worry ;-)

regards,
Armin

Daniel Perry wrote:

> No problem...
> 
> Instead of doing:
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> 
> Use
> broker = PersistenceBrokerFactory.createPersistenceBroker(new
> PBKey("jcdAlias"));
> Where jcdAlias is the alias you gave the connection in
> repository_database.xml.
> 
> I'm pretty sure you can do it using the other APIs aswell, just never tried
> myself.
> 
> Daniel.
> 
> 
> 
>>-----Original Message-----
>>From: Marc Tinnemeyer [mailto:marc-web@gmx.net]
>>Sent: 09 December 2004 10:28
>>To: ojb-user@db.apache.org
>>Subject: switching between databases
>>
>>
>>hi everybody,
>>
>>i got a question concerning ojb.
>>
>>i have several applications (multiple customers) using different
>>databases. the databases all share the same structure, so my idea is to
>>create a global application the customers can use to perfrom some
>>administrative actions.
>>
>>that app will be globally installed (so it can be easily maintained)
>>and is then mapped to the correct uris where it can be reached e.g.
>>through:
>>
>>https://abc.com/admin
>>and
>>https://def.com/admin
>>
>>and now i'd like to know if it is possible to definie multiple databases
>>in ojb (in repository_database.xml) that can be switched depending on
>>the url that is called ?
>>
>>there will be a mapping like:
>>
>>abc.com -> db1
>>def.com -> db2
>>
>>is this possible ?
>>
>>big thanks in advance
>>
>>Marc Tinnemeyer
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: switching between databases

Posted by Daniel Perry <d....@netcase.co.uk>.
No problem...

Instead of doing:
broker = PersistenceBrokerFactory.defaultPersistenceBroker();

Use
broker = PersistenceBrokerFactory.createPersistenceBroker(new
PBKey("jcdAlias"));
Where jcdAlias is the alias you gave the connection in
repository_database.xml.

I'm pretty sure you can do it using the other APIs aswell, just never tried
myself.

Daniel.


> -----Original Message-----
> From: Marc Tinnemeyer [mailto:marc-web@gmx.net]
> Sent: 09 December 2004 10:28
> To: ojb-user@db.apache.org
> Subject: switching between databases
>
>
> hi everybody,
>
> i got a question concerning ojb.
>
> i have several applications (multiple customers) using different
> databases. the databases all share the same structure, so my idea is to
> create a global application the customers can use to perfrom some
> administrative actions.
>
> that app will be globally installed (so it can be easily maintained)
> and is then mapped to the correct uris where it can be reached e.g.
> through:
>
> https://abc.com/admin
> and
> https://def.com/admin
>
> and now i'd like to know if it is possible to definie multiple databases
> in ojb (in repository_database.xml) that can be switched depending on
> the url that is called ?
>
> there will be a mapping like:
>
> abc.com -> db1
> def.com -> db2
>
> is this possible ?
>
> big thanks in advance
>
> Marc Tinnemeyer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org