EDIT: Criteria c = new Criteria(ProductPeer.DATA_BASE_NAME);
From: Aaron Loucks [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 17, 2005 5:02 PM To: Apache Torque Users List Subject: TorqueInstance & non-static initialization Help! I'm trying to initialize torque in a non-static way so that I can have multiple instances (for different databases/functionality) in a single web application. I tried initializing a TorqueInstance and pass the database name and connection to a peer class, without success: ... TorqueInstance torqueInstance = new TorqueInstance(); torqueInstance.setConfiguration(config); torqueInstance.initalize(); Criteria c = ProductPeer.DATABASE_NAME; List list = ProductPeer.doSelect(c, torqueInstance.getConnection()); java.lang.NullPointerException at org.apache.torque.TorqueInstance.getDB(TorqueInstance.java:772) at org.apache.torque.Torque.getDB(Torque.java:299) at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:918) at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1221) at test.torque.BaseProductPeer.doSelectVillageRecords(BaseProductPeer.java: 664) at test.torque.BaseProductPeer.doSelect(BaseProductPeer.java:607) at test.torque.Product.lookup(Product.java:318) at test.actions.Test1.execute(Test1.java:63) ... I looked into the source code a bit, and saw that the static Torque wrapper creates a new instance of TorqueInstance if the static torqueSingleton is null. This leads me to believe that what I'm trying to do isn't possible, but according to the change log, this feature was implemented long ago: Release 3.1-BETA1 - 2003-08-19 update Introduced the TorqueInstance class to do away with static initialization woes and allow multiple instances of Torque per ClassLoader. Apparently, I'm missing something... Any help would be highly appreciated. Aaron Loucks Web Developer Gardner, Inc. 3641 Interchange Road Columbus, OH 43204 614.456.3492 --------------------------------------------------------------------- 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]
