db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: nullpointer BasePeer
Date Thu, 02 Jun 2005 15:06:39 GMT




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 <r.kromkamp@pagelink.nl> 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 <r.kromkamp@pagelink.nl> 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


Mime
View raw message