Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 26433 invoked from network); 3 Jun 2005 09:24:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Jun 2005 09:24:32 -0000 Received: (qmail 61704 invoked by uid 500); 3 Jun 2005 09:24:29 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 61683 invoked by uid 500); 3 Jun 2005 09:24:29 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: 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 61670 invoked by uid 99); 3 Jun 2005 09:24:29 -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; Fri, 03 Jun 2005 02:24:27 -0700 Received: from [195.127.188.18] (helo=www.seitenbau.net) by router1.seitenbau.net with esmtp (Exim 4.43) id 1De8PM-0006r8-U8 for torque-user@db.apache.org; Fri, 03 Jun 2005 11:24:04 +0200 In-Reply-To: Subject: RE: nullpointer BasePeer To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Thomas Fischer Date: Fri, 3 Jun 2005 11:24:04 +0200 X-MIMETrack: Serialize by Router on www/seitenbau(Release 6.5.1|January 21, 2004) at 03.06.2005 11:24:03 AM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Robert, the query looks ok to me. This is not the problem. Hopefully you can debug your code. If yes, try to locate the static initializer in your AdresPeer class. It is quite at the beginning and it looks like the following (with changed variable names,). ... /** the column name for the NAME field */ public static final String NAME; /** the column name for the VORNAME field */ public static final String VORNAME; static { NAME = "benutzer.NAME"; VORNAME = "benutzer.VORNAME"; if (Torque.isInit()) ... Try to put a breakpoint into the first line into the "static { " block, i.e. in my case the line "NAME = "benutzer.NAME";". Do the same for one other class with which you have no problem (just to see that the breakpoints work at tthat place) Then put also a breakpoint at your doSelect statement. Start your application and see whether the static initializer gets called before the select. If yes, debug into the following lines of the static initializer. There, the Adres Map builder should be put into the dbMap. Please mail back to the list with your findings. Thomas Robert Kromkamp schrieb am 03.06.2005 10:48:58: > Hi Thomas, > > Thanks for your reaction and time! I've tried really a lot, also changed the > orderning of calling methods, but nothing solved the error. I still get the > NullPointer, cause the Adres table is not in the dbMap, while I try to sort > on it. > > String package = 'nl.pagelink.torque.opm'; > String table = 'OBJECTEN'; > String column = 'NAAM_OBJECT'; > String class = 'Objecten'; > String value = "%drie%"; > > Criteria critiera = new Criteria(); > Criterion criterion = criteria.getNewCriterion (table+"."+column, value, > criteriaObject.ILIKE); > criteria.add(criterion); > criteria.addJoin(ObjectenPeer.OBJECT_ID, ObjectAdresPeer.OBJECT_ID); > criteria.addJoin(ObjectAdresPeer.ADRES_ID, AdresPeer.ADRES_ID); > criteria.addAscendingOrderByColumn("ADRES.POSTCODE"); > > List objecten = ObjectenPeer.doSelect(criteria); > > It result in the following query: > > SELECT OBJECTEN.OBJECT_ID, OBJECTEN.NAAM_OBJECT, > OBJECTEN.X_COORDINAAT_ADRES, OBJECTEN.Y_COORDINAAT_ADRES, > OBJECTEN.Z_COORDINAAT_ADRES, UPPER(ADRES.ADRES_ID) FROM OBJECTEN, > OBJECT_ADRES, ADRES WHERE OBJECTEN.NAAM_OBJECT ILIKE '%drie%' AND > OBJECTEN.OBJECT_ID=OBJECT_ADRES.OBJECT_ID AND > OBJECT_ADRES.ADRES_ID=ADRES.ADRES_ID ORDER BY UPPER(ADRES.ADRES_ID) ASC > > There are no columns of the joined tables in the query, is this correct? > > Hopefully I forgot something ... perhaps do you have some new ideas? > > Robert > > -----Original Message----- > From: Thomas Fischer [mailto:fischer@seitenbau.net] > Sent: donderdag 2 juni 2005 17:07 > To: Apache Torque Users List > Subject: RE: nullpointer BasePeer > > > > > > > Hi, > > your problem is that you do not use the constants in the peer class to > create the link, but use String constants instead. For example, you use > > criteria.addJoin("OBJECTEN.OBJECT_ID", "OBJECT_ADRES.OBJECT_ID"); > > instead of (hopefully I got the name of the constants right) > > criteria.addJoin(ObjektenPeer.OBJECT_ID, ObjectAdresPeer.OBJECT_ID); > > If you do not access a Peer class before executing a query which uses > information from this Peer, the problem occurs. > > If you are interested in the background, see > http://issues.apache.org/scarab/issues/id/TRQS228 > > Thomas > > > > Robert Kromkamp schrieb am 01.06.2005 16:05:17: > > > Hi Thomas, > > > > Thanks for your reaction! I'm using Torque 3.1.1. I really don't know > what > > is going wrong. > > > > I'm sure I added the adres into the schema.xml. When I change the order > by > > to the top table (on which the doSelect is executed), everything works > fine > > and I also get addresses in my result. > > > > I've 3 tables which are involved in my example, namely > > > > OBJECTEN (top) > > OBJECT_ADRES (Mapping table which has a foreign key to Objecten and a > > Foreign Key to Adres ) > > ADRES (Contains the order by) > > > > String package = 'nl.pagelink.torque.opm'; > > String table = 'OBJECTEN'; > > String column = 'NAAM_OBJECT'; > > String class = 'Objecten'; > > String value = "%drie%"; > > String comparator = 'ILIKE'; > > > > Criteria critiera = new Criteria(); > > Criterion criterion = criteria.getNewCriterion (table+"."+column, value, > > criteriaObject.ILIKE); > > criteria.add(criterion); > > criteria.addJoin("OBJECTEN.OBJECT_ID", "OBJECT_ADRES.OBJECT_ID"); > > criteria.addJoin("OBJECT_ADRES.ADRES_ID", "ADRES.ADRES_ID"); > > criteria.addAscendingOrderByColumn("ADRES.POSTCODE"); > > > > List objecten = ObjectenPeer.doSelect(criteria); > > > > > > This occurs the following exception: > > > > java.lang.reflect.InvocationTargetException > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown > Source) > > at java.lang.reflect.Method.invoke(Unknown Source) > > at > > nl.pagelink.engine.common.CommonEngine.getObjectsByCriteria(Unknown S > > ource) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown > Source) > > at java.lang.reflect.Method.invoke(Unknown Source) > > at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) > > at sun.rmi.transport.Transport$1.run(Unknown Source) > > at java.security.AccessController.doPrivileged(Native Method) > > at sun.rmi.transport.Transport.serviceCall(Unknown Source) > > at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown > Source) > > at > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown > > Sour > > ce) > > at java.lang.Thread.run(Unknown Source) > > Caused by: org.apache.torque.TorqueException: > java.lang.NullPointerException > > at > > org.apache.torque.util.BasePeer.throwTorqueException(BasePeer.java:20 > > 0) > > at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1204) > > at > > nl.pagelink.torque.opm.BaseObjectenPeer.doSelectVillageRecords(BaseOb > > jectenPeer.java:402) > > at > > nl.pagelink.torque.opm.BaseObjectenPeer.doSelectVillageRecords(BaseOb > > jectenPeer.java:374) > > at > > nl.pagelink.torque.opm.BaseObjectenPeer.doSelect(BaseObjectenPeer.jav > > a:343) > > ... 16 more > > Caused by: java.lang.NullPointerException > > at > org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1148) > > at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1221) > > at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1198) > > ... 19 more > > > > > > When I a print the dbMap before the error occurs, I see only the tables > > ID_TABLE and OBJECTEN are stored in dbMap. > > Because of the order by it needs to know the type of the column, but the > > Adres table is not part of the dbMap. > > Result -> NullPointer. Does anyone know why Adres is not in the dbMap? Is > > something missing in the criteria? > > > > > > Met vriendelijke groet, > > Robert Kromkamp > > > > > > > > Pagelink | improves business > > > > Bornsestraat 1d > > 7556 BA Hengelo > > > > Postbus 76 > > 7550 AB Hengelo > > > > tel 074 750 12 50 > > fax 074 750 12 51 > > > > mailto:r.kromkamp@pagelink.nl > > http://www.pagelink.nl > > http://www.perrit.nl > > http://www.armeo.nl > > > > > > -----Original Message----- > > From: Thomas Fischer [mailto:fischer@seitenbau.net] > > Sent: dinsdag 31 mei 2005 9:05 > > To: Apache Torque Users List > > Subject: RE: nullpointer BasePeer > > > > > > > > > > > > > > Hi, > > > > Is the table you want to use for joining (Adres) in your schema.xml ? > > > > If not, you have to put it in there (this means you have to edit the db > > scripts manually in order not to create and drop that table > automatically, > > but that is the price to pay) > > > > If yes, which Torque version are you using and which is the exact code > you > > use to do the join ? > > > > Thomas > > > > Robert Kromkamp schrieb am 30.05.2005 14:50:04: > > > > > Hi all, > > > > > > I'm trying to do a query with an order by on a foreign table. > > > A foreign table means another table than the one on which the doSelect > is > > > executed. By example: > > > > > > Get a person (PersonPeer executes the doSelect query) and order by > > Zipcode > > > (Adres is the foreign orderby table) > > > > > > When i execute this i will get an error in BasePeer.java on line 1148: > > > > > > ColumnMap column = dbMap.getTable(table).getColumn(columnName); > > > > > > The adres table is not part a the dbMap (the Person table is part of > it). > > > Is this a bug, do I do something wrong or does anyone have a solution? > > > > > > Cheers, > > > Robert > > > > > > --------------------------------------------------------------------- > > > 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 > > --------------------------------------------------------------------- > 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