db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Gordon <rgor...@mwt.net>
Subject Re: Torque with more dynamic DB connections...
Date Tue, 06 Jan 2004 03:51:48 GMT
I see upon further investigation that the MapBuilder classes would have to
be touched also. The <table-name>MapBuilder class does a call to
Torque.getDatabaseMap("hard-coded-database-name") in the doBuild
method. This is called by the BasePeer.  Somehow,
the database name has to be passed down to the BasePeer before it calls
doBuild. This would require changing the MapBuilder interface by adding
a setDatabaseName().

Any developer want to chime in here?

Rob.

Rob Gordon wrote:

> I have been following thread regarding using a TorqueInstance with
> multiple
> databases, etc.
>
> I have a similar wish and a proposed solution, if I can get the
> eyes/ears of a developer.
>
> I want to be able to use the same tables (ie Peers) across multiple
> databases. It just so
> happens, for a data collection application, I will have "many" databases
> with same
> schema. The data collection application will be configured at start-up
> with the name of
> the db to which it should write data.
>
> Hence, I want my peers to have their DATABASE_NAME set at runtime, not
> in
> a static final as is currently done.
>
> My proposal/question/wish is that the templates/om/Peer.vm be changed to
>
> include  setDatabaseName()/getDatabaseName() and all the references to
> DATABASE_NAME be changed to invoke the appropriate method.
>
> Here is a snippet from Peer.vm
>
>  public static $table.JavaName ${retrieveMethod}(ObjectKey pk)
>         throws TorqueException, NoRowsException, TooManyRowsException
>     {
>         Connection db = null;
>         $table.JavaName retVal = null;
>         try
>         {
>  /* here */           db = Torque.getConnection(DATABASE_NAME);
>             retVal = ${retrieveMethod}(pk, db);
>         }
>         finally
>         {
>             Torque.closeConnection(db);
>         }
>         return(retVal);
>     }
>
> Why couldn't the line I have labelled /* here */ read
>
>     db = Torque.getConnection(getDatabaseName());
>
> with  appropriate accessors methods and instance variable supplied by
> Peer.vm???
>
> I am by no means a Torque expert but does this violate any usage idioms?
>
> Thanks
> Rob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org


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


Mime
View raw message