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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]