db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Vandahl ...@apache.org>
Subject Re: TorqueSecurityService fails tests/NPE in BasePeer
Date Sun, 26 Aug 2007 17:29:55 GMT
Thomas Fischer wrote:
> I'm not sure if I understand the turbine initialisation process of
> Torque correctly. I assume the following (correct me if I'm wrong):
> 
> 1) Torque.init(...) is called before a select is attempted.
Yep.

> 2) In the configuration provided to Torque.init(), the key
> "torque.database.default" is set to the value "default"
No. The relevant part of the configuration is like this:

---8<---
torque.database.default = test

torque.database.test.adapter = hypersonic

torque.dsfactory.test.factory =	\
  org.apache.torque.dsfactory.SharedPoolDataSourceFactory
torque.dsfactory.test.connection.driver = org.hsqldb.jdbcDriver
torque.dsfactory.test.connection.url =	jdbc:hsqldb:.
torque.dsfactory.test.connection.user = sa
torque.dsfactory.test.connection.password =
---8<---

Everything looks quite normal to me.

> If this is the case, in TorqueInstance.java line 314ff it is ensured
> that the database "default" is not null.
> 
> Maybe this is relevant: I remember dimly that there was some mad logic
> with the word "default" when the default database was not set, which was
> used by turbine. I removed this logic during clean-up of the torque
> initialisation process back in 2005. I'd guess this is the relevant
> commit message:
> http://mail-archives.apache.org/mod_mbox/db-torque-dev/200507.mbox/%3C20050708175334.64249.qmail@minotaur.apache.org%3E
> 

The important line is in BasePeer.doSelect(criteria, con)

        DB dbadapter = Torque.getDB(criteria.getDbName());

Here, the database name in criteria is "default", which points to the
reference to "test". Because during the setup, only the
DataSourceFactory is copied to the reference, in the reference Database
object the adapter is null. In the next lines of BasePeer

        // Call Village depending on the capabilities of the DB
        return executeQuery(query.toString(),
                dbadapter.supportsNativeOffset() ? 0 :
                  criteria.getOffset(),
                dbadapter.supportsNativeLimit() ? -1 :
                  criteria.getLimit(),
                criteria.isSingleRecord(),
                con);

this must lead to a NullPonterException.

Now the question is: Why doesn't this happen all the time? I remember
some strange mapping code which replaces the "default" in Criteria with
the actual name of the default database but I can't find it anymore.

Should I simply commit that change to TorqueInstance (adding the adapter
to the reference as well?)

Bye, Thomas.

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message