The example given does not help much in determining what your problem
is. Of course the tableMap is going to be null if it has not yet been
added to the databaseMap. The tableMap should be added to the
databaseMap when you first make reference to the table. I do not know
how you are building a Criteria that includes columns from a particular
table without causing the tableMap to be loaded. Showing how you are
building the criteria could help shed some light on the problem.
john mcnally
Nick Pomfret wrote:
>
> Thanks for the prompt reply.
>
> We're using TDK2.1
>
> I can't send you the schema right now, but I will put one together that will
> reproduce the problem.
>
> Its quite simple: if you have two tables joined by a foreign key, and
> neither table has been called by TDK before, build a criteria object, add
> the necessary join to it, then call doSelect(criteria) on one of the tables.
> This will throw a NullPointerException.
>
> Or, alternatively.
>
> Using a table that has never been called in your TDK app:
>
> DatabaseMap dbMap = TurbineDB.getDatabaseMap("default");
>
> TableMap[] tableMaps = dbMap.getTables();
>
> TableMap tableMap = dbMap.getTable("never_touched_before");
>
> /* tableMap will be null, so this next line throws a NullPointerException
> */
> tableMap.containsObjectColumn();
>
> -----Original Message-----
> From: Jason van Zyl [mailto:[EMAIL PROTECTED]]
> Sent: 20 November 2001 15:38
> To: Turbine Users List
> Subject: Re: missing tableMaps
>
> On 11/20/01 7:38 AM, "Nick Pomfret" <[EMAIL PROTECTED]> wrote:
>
> > When performing a select (using a Criteria object) containing a join to a
> > table, if that has never been selected from before (in the Turbine app) I
> > get the following error:
> >
> > Exception: java.lang.NullPointerException:
> > Stack Trace follows:
> > java.lang.NullPointerException:
> > at
> >
> org.apache.turbine.util.db.Criteria.containsObjectColumn(Criteria.java:393)
> > at org.apache.turbine.om.peer.BasePeer.doSelect(BasePeer.java:1111)
> >
> > I've discovered through querying the databaseMap that the tableMap in
> > question does not exist. Is it true that a tableMap is loaded into a
> > databaseMap only when performing a select on its table (it seems so)?
>
> Yes, Torque has some odd initialization patterns which will be cleaned up to
> be more deterministic. Trying to find the source of initialization can be
> very, very confusing and looking at a sequence diagram leaves you scratching
> your head.
>
> Are you using Torque in 2.x or the decoupled Torque? Can you send me your
> datamodel and your code that is causing this? I will add it to the testbed
> and fix the problem.
>
> > If so
> > is there a way to configure turbine to load all the tableMaps in when it
> > starts up? Or is there another solution?
>
> They will load when the system starts up in a deterministic way. The system
> may take up a few more resources given that the lazy initialization will be
> removed but I believe it will make the code a lot easier to understand. With
> your discovery as a case in point I don't know of any common
> misconfiguration that might be causing the problem and I don't know what's
> going on until I see your code. John often has more insight into Criteria
> related behaviour as I haven't delved into that class in earnest because I
> would like to make the query model pluggable so queries can be made in terms
> of the object model and not the datamodel.
>
> > Nick
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
>
> jvz.
>
> Jason van Zyl
>
> http://tambora.zenplex.org
> http://jakarta.apache.org/turbine
> http://jakarta.apache.org/velocity
> http://jakarta.apache.org/alexandria
> http://jakarta.apache.org/commons
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>