> 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.
Ok, understood. By the way, before going any further, let me
apologize if my question sounded in any way like a complaint.
I was just trying to understand how things work.
> > 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.
I wasn't saying anything about how things should be done;
I don't know near enough about the peer model to be able
to provide such input. I was simply asking: if I set the
Criteria's dbName when I create it, why is other code
changing that dbName somewhere else?
> > 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?
Yes, it was. The only purpose of reporting the log was to
point out who would probably know more about this. I was not
in any way implying the code is wrong! Again, apologies if I
came through that way. As far as I can gather from the list,
John, your contributions to Turbine have been many and great!
> 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?
I have come to the same conclusion. I thought this change:
User: dlr
Date: 01/02/01 11:08:48
Modified: src/java/org/apache/turbine/om/peer BasePeer.java
Log:
Changed references to magic string "default" to
TurbineDB.getDefaultDB().
could have an impact in this problem, but it didn't. (And again,
I'm only pointing to the ChangeLog entry to provide as much
information as I can, not to point fingers.)
> John McNally
Thanks for the information,
--
Gonzalo A. Diethelm
[EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]