Hi,

I can reproduce your behaviour. However, I would not call it a bug, rather an unsupported feature of Torque.

The problem ist the following: If you use more than one database, Torque knows internally which objects belong to which database, and it also keeps a map of known tables for each database (the database map). One object can only belong to one database. When deleting, for some reason which is not totally clear to me at the moment, Torque needs to know whether a column you used in the criteria is a primary key. It does so looking at the database map for the database. So it appears that Invoices were compiled as belonging to db1, and if you want to delete an invoice from db2, it is not able to locate the invoices in the database map for db2 and thus throws a null pointer exception.

I know no easy way how this can be changed at the moment. The problem is rooted deeply in the architecture of Torque. Perhaps someone else got an idea, now that the reason for the problem is known. Perhaps you can manipulate the database map manually in some way (though I'd call that not a solution but a hack) (this should be done best in a static initializer of the InvoicePeer class)

   Thomas

On Fri, 19 Aug 2005, John Dunne wrote:

I'm of the thinking that this is a bug? I've been able to workaround the problem by getting a java.sql.Connection directly to the database and issuing delete statements via the connection's java.sql.Statement object (for those who come across this problem in future).

John.
John Dunne wrote:

Hello all,

Any help on this problem would be gratefully appreciated.

Im getting a null pointer exception when I call doDelete (see code)

     Criteria crit = new Criteria(databasename);
     crit.add(InvoicesPeer.INVOICEID);
     InvoicesPeer.doDelete( crit);

I've got two databases in MySQL (version 3) both with identical schemas. The default database is set to 'db1' and the exception is only thrown when databasename is set to 'db2'. The COM objects were compiled from a schema that identified the database name as 'db1' (so BaseInvoicesPeer has DATABASE_NAME='db1'; ), so i;m wondering if this is the problem, but then whats the point in specifing the database name to Critera!

Further, I believe that Torque is configured proberly since I can query (doSelect) and retrieve the contents of both db1 and db2. This problem only occurs when I call doDelete!

John.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to