"Diethelm Guallar, Gonzalo" wrote:
>
> In all generated BaseFooPeer classes, torque does something
> like this:
>
> /** Method to do selects */
> public static Vector doSelect( Criteria criteria ) throws Exception
> {
> criteria.setDbName(getMapBuilder().getDatabaseMap().getName());
> return doSelect (criteria,"com.bice.Cartola", null);
> }
>
> Why is the name of the Criteria being forced?
torque objects are created from a schema in where you have a
<database name="foo">
tag. If name is omitted, the default is "default". Since the torque om
represent tables inside "foo" database, they should know that they
belong in "foo" database. It is the proper place to set the db name,
from an OO perspective. If you have a similar table in another db, it
should have its own om/peer objects. I do not see any reason you need
to specify the database anywhere else.
> As far as I
> understood, the only way to specify a DB other than "default"
> was to create a Criteria object with the DB name as a parameter,
> and have TR.props configured for a DB with that name. But
> this code is forcing the name to something else; is this
> correct?
It is correct. You do have to have connection settings for the db,
"foo", in TR.props as well. And you do have to set the db name in the
Criteria, that is what the above code is supposed to do. I am not sure
why you would want to set it somewhere else, please tell me where is the
more appropriate place. I do not see why the rest of your app needs to
concern itself with where to save the object's data when it already
knows where it should go.
>
> Looking at the cvs log, this change seems to have been
> introduced by John McNally with release 1.6 of file
>
> conf/torque/templates/om/Peer.vm
This was added on Dec. 6, when I fixed a lot of code that was making
using turbine with multiple databases more difficult than it needed to
be. Was your next to last update couple months ago?
Looking at the following code:
> /** Method to do selects */
> public static Vector doSelect( Criteria criteria ) throws Exception
> {
> criteria.setDbName(getMapBuilder().getDatabaseMap().getName());
> return doSelect (criteria,"com.bice.Cartola", null);
> }
>
I have determined that getMapBuilder().getDatabaseMap().getName() is
always returning "default". I have not determined why. In an example
app where I do not define a "default" db, only a "foo" db, all the
torque map builders are adding tables to a DatabaseMap whose getName()
method returns "foo". And yet the call here is not returning the
correct DatabaseMap, I believe. Any clues?
John McNally
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]