Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 5700 invoked from network); 15 Mar 2005 07:40:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 15 Mar 2005 07:40:21 -0000 Received: (qmail 84949 invoked by uid 500); 15 Mar 2005 07:40:19 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 84926 invoked by uid 500); 15 Mar 2005 07:40:19 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 84908 invoked by uid 99); 15 Mar 2005 07:40:19 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.seitenbau.net (HELO mail.seitenbau.net) (194.175.229.106) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 14 Mar 2005 23:40:18 -0800 Received: from [195.127.188.18] (helo=www.seitenbau.net) by router1.seitenbau.net with esmtp (Exim 4.43) id 1DB6f1-0005W5-Ai for torque-user@db.apache.org; Tue, 15 Mar 2005 08:40:15 +0100 In-Reply-To: Subject: RE: doDelete problem, null dbMap To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Thomas Fischer Date: Tue, 15 Mar 2005 08:40:14 +0100 X-MIMETrack: Serialize by Router on www/seitenbau(Release 6.5.1|January 21, 2004) at 15.03.2005 08:40:14 AM MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: quoted-printable X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Jim, Sorry, I should have read your mail more cautiously; I was again mistaken... But nonetheless, I am still confused. There should be code in the generated xxxBasePeer class which looks lik= e public static MapBuilder getMapBuilder(String name) { try { MapBuilder mb =3D (MapBuilder) mapBuilders.get(name); // Use the 'double-check pattern' for syncing // caching of the MapBuilder. if (mb =3D=3D null) { synchronized (mapBuilders) { mb =3D (MapBuilder) mapBuilders.get(name); if (mb =3D=3D null) { mb =3D (MapBuilder) Class.forName(name).newInstance(); // Cache the MapBuilder before it is built. mapBuilders.put(name, mb); } } } .... This should cache the map builder in the dbMap. The method is called fr= om the static initializer of the xxxBasePeer class, which should be called= at the latest when you call xxxPeer.DoDelete(). If you have the possibilit= y to debug your code, you might want to put a breakpoint in there and see whether and when it it called. There are two reasons I can think of why the Table does not appear in t= he dbMap (there might be more) 1) Torque is not initialized or it is initialized more than once 2) For some obscure reason, the xxxBasePeer class is not loaded while y= ou execute the doDelete(). To exclude 2), you can force the classLoader to load the xxxBasePeer cl= ass by issuing class.ForName("fully.qualified.name.of.xxxBasePeer"); before the delete. But ") is very improbable, as the Java Language specification explicitly states that a class is loaded immediately befo= re you execute one of its static methods.... JLS 2.0 =A712.4.1-- "A class or interface type T will be initialized immediately before the= first occurrence of any one of the following: . T is a class and an instance of T is created. . T is a class and a static method declared by T is invoked. . A static field declared by T is assigned. . A static field declared by T is used and the reference to the field i= s not a compile-time constant (=A715.28). References to compile-time cons= tants must be resolved at compile time to a copy of the compile-time constant= value, so uses of such a field never cause initialization." If you can solve this, I (and probably some more people on the list) wo= uld be very interested to know how this problem could originate. Thomas jcaserta@chubb.com schrieb am 14.03.2005 19:49:22: > > Tom, > > Yes it does. In the tables MapBulder class it has the following: > > dbMap =3D Torque.getDatabaseMap("default"); > dbMap.addTable("PMTEM021_POLOFFR"); > TableMap tMap =3D dbMap.getTable("PMTEM021_POLOFFR"); > tMap.setPrimaryKeyMethod("none"); > tMap.addPrimaryKey("PMTEM021_POLOFFR.OFFRG_N", new String()); > > > > Jim Caserta > > Whitehouse Station CCI - PM&M Systems > > Office: (908) 572-4788 > > Mail Stop: WHB2S-15 > > jcaserta@chubb.com > > > > > > > > Thomas Fischer > u.net> To > "Apache Torque Users List" > 03/14/2005 10:44 > AM cc > > Subject > Please respond to RE: doDelete problem, null dbM= ap > "Apache Torque > Users List" > pache.org> > > > > > > > > > > > Jim, > > if the db map is not null, but the column is not mapped, then I was > mistaken about the cause of the error, and class.forName() is of no u= se. > > Can you look at the map package (${target.package}.map), locate the M= ap > class for the Table, and see if it has got an entry for the column OFFRG_N > ? > > Thomas > > > jcaserta@chubb.com schrieb am 11.03.2005 20:51:27: > > > Thomas, > > > > This is exactly (well.. almost) what I have in my code > > > > //Get a connection > > dbConn =3D Torque.getConnection(getProperty("db2.environment")); > > dbConn.setAutoCommit(true); > > > > \\db2Schema is the High level qualifier for the table > > String db2Schema =3D MixApplication.getProperty("db2schema"); > > > > BaseTableNamePeer.executeStatement("SET CURRENT SQLID =3D '" + db2S= chema + > > "'", dbConn); > > BasePeer.executeStatement("SET CURRENT SQLID =3D '" + db2Schema + "= '", > dbConn > > ); > > > > Criteria criteria =3D new Criteria(); > > criteria.add(TableNamePeerPeer.OFFRG_N, primaryKey); > > TableNamePeer.doDelete(criteria, dbConn); > > > > By the way, the dbMap was not null, dbMap.getTable(tab) is null.. m= y > > mistake. > > ColumnMap[] columnMaps =3D dbMap.getTable(tab).getColumns(); > > > > How are you are suggesting I should use the forName()? > > > > Thanks again! > > Jim > > > > > > > > > > > > John, > > > > My first guess would be that the Peer class is not loaded by the > > classloader before you execute the query. See > > http://issues.apache.org/scarab/issues/id/TRQS228 > > In Torque 3.1.1, the problem should be resolved. Alternatively, you= can > > force the classloader to load the class before you execute the statement, > > e.g. by class.forName(); > > > > By the way, what is TableNamePeer.PRIMARY ? Never seen that before;= I > > normally would use > > TableNamePeer.doDelete(criteria, dbConn); > > > > Thomas > > > > jcaserta@chubb.com schrieb am 11.03.2005 16:35:13: > > > > > I recently moved over to version 3.1 for Java, I have the selects= > working > > > fine now (Thanks). The issue is on a doDelete, the dbMap is null.= The > > error > > > is occurring on this line: > > > ColumnMap[] columnMaps =3D dbMap.getTable(tab).getColumns(); in t= he > > doDelete. > > > > > > My Criteria is setup as follows: > > > Criteria criteria =3D new Criteria(); > > > criteria.add(TableNamePeer.PRIMARY_KEY, primaryKey); > > > TableNamePeer.PRIMARY.doDelete(criteria, dbConn); > > > > > > This is the main DB2 table and there are many beneath it. Our sys= tem > will > > > automatically handle the cascading of the delete. This worked fin= e in > > 3.0. > > > > > > Thank you in advance! > > > Jim > > > > > > > > > > Jim Caserta > > > > > > Whitehouse Station CCI - PM&M Systems > > > > > > Office: (908) 572-4788 > > > > > > Mail Stop: WHB2S-15 > > > > > > jcaserta@chubb.com > > > > > > > > > > > > > > -------------------------------------------------------------------= -- > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > > For additional commands, e-mail: torque-user-help@db.apache.org > > > > > ---------------------------------------------------------------------= > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > For additional commands, e-mail: torque-user-help@db.apache.org > > > > ---------------------------------------------------------------------= > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > For additional commands, e-mail: torque-user-help@db.apache.org >= --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org