db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Damien SAUVAGEOT" <dsauvag...@omnikles.com>
Subject Multiple Database
Date Mon, 26 May 2003 15:35:13 GMT

I am new to torque and I am facing a problem connecting to multiples databases using
the same java code generated by torque.
I need to connect to 2 databases (A and B) defined with the same XML torque schema.
In order to process a select, I do : 

Connection c = null;
c = DriverManager.getConnection(getDburl(),getDbusername(),getDbpass());
List v;
v = AliasPeer.doSelect(crit, c);

This connect to the database A and works fine, 
I then iterate on the 'v' list :
                    while (i.hasNext()) {
                        Alias alias = (Alias) i.next();

and then need to retrieve a object customer which is a foreign key
in alias. So alias.getCustomer() should retrieve me that object.
In fact, it seems to retrieve it from the B database as in BaseCustomersPeer.java
there is 
    public static final String DATABASE_NAME = "B";
which is used by 
    public static Customers retrieveByPK(ObjectKey pk)
        throws TorqueException {
        Connection db = null;
        Customers retVal = null;
        try {
            Log.getAppLogger().info("database connection : " + DATABASE_NAME);
            db = Torque.getConnection(DATABASE_NAME);
            retVal = retrieveByPK(pk, db);
        } finally {
        return (retVal);

Does it mean that torque needs to generate java files for each database even if it is the
same database?
I could always give the connection c as I do for do Select, but this is not working for all
functions as
in this case.

Does someone has a solution?


View raw message