db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: Criteria surprises
Date Wed, 04 Dec 2002 16:12:46 GMT
"Erik Wright" <twodigits@sympatico.ca> writes:


>I have a question regarding the implementation of Criteria.

>I'm developing an app that uses several databases (three at
>the moment) - currently they are all hosted on one instance
>of MySQL but in production this may not be the case.

>The problem has to do with the multiple DBs. Criteria built
>using the default constructor automatically select the
>default database. As you can imagine, two times out of three
>this is wrong in my scenario.

>Is there a particular reason why this should be necessary?
>My first instinct is that by default the Criteria shouldn't
>care too much about what DB is being used until it comes
>time to build the SQL query, and that this should then be
>supplied by the Base Peer. At first thought, this change

You're right but with the current state and relation of the
BasePeer, it simply doesn't work that way. Sorry.

Please use the Criteria(String s) C'tor and supply the name of
the database. 

Alternatively, if you configured the symbolic names of your
db correct in the xml file and the .properties, the Criteria
automagically _should_ select the right DB.

I BTW use the same thing (three databases, one server, MySQL)
and have this:


torque.database.db1.adapter = mysql
torque.dsfactory.db1.factory= org.apache.torque.dsfactory.TorqueDataSourceFactory
torque.dsfactory.db1.connection.driver   = org.gjt.mm.mysql.Driver
torque.dsfactory.db1.connection.url      = jdbc:mysql://localhost:3306/FIRST_DATABASE
torque.dsfactory.db1.connection.user     = root
torque.dsfactory.db1.connection.password = 

torque.database.db2.adapter = mysql
torque.dsfactory.db2.factory= org.apache.torque.dsfactory.TorqueDataSourceFactory
torque.dsfactory.db2.connection.driver   = org.gjt.mm.mysql.Driver
torque.dsfactory.db2.connection.url      = jdbc:mysql://localhost:3306/SECOND_DATABASE
torque.dsfactory.db2.connection.user     = root
torque.dsfactory.db2.connection.password = 

torque.database.db3.adapter = mysql
torque.dsfactory.db3.factory= org.apache.torque.dsfactory.TorqueDataSourceFactory
torque.dsfactory.db3.connection.driver   = org.gjt.mm.mysql.Driver
torque.dsfactory.db3.connection.url      = jdbc:mysql://localhost:3306/THIRD_DATABASE
torque.dsfactory.db3.connection.user     = root
torque.dsfactory.db3.connection.password = 

in my database definition properties. In the XML file I have

<database name="db1">
[...tables from db1...]

<database name="db2">
[...tables from db2...]

<database name="db3">
[...tables from db3...]

and the resulting peers and stuff simply "work". You must use the Peer
supplied constants for the column names, however.


Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

View raw message