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: hsqldb and NullPointerException
Date Fri, 17 Jun 2005 14:21:34 GMT




Ok, so far we have
- Torque is initialized when PatientBasePeer is loaded
- No exception is thrown when BasePeer.getMapBuilder(String) is called
(this does not mean anything, see below)

Fisr path of action is looking into the Map builder. It is located in the
map subpackage of the package where you generate the OM classes in and is
called
PatientMapBuilder.

It should have a doBuild() method, which should get called by the line

getMapBuilder(PatientMapBuilder.CLASS_NAME);

in the static initializer of PatientPeer.

The dobuild() method should look similar to this:
    public void doBuild() throws TorqueException
    {
        dbMap = Torque.getDatabaseMap("nameOfYourDefaultDb");

        dbMap.addTable("benutzer");
        TableMap tMap = dbMap.getTable("benutzer");

        tMap.setPrimaryKeyMethod("none");


              tMap.addPrimaryKey("benutzer.NSUNIQUEID", new String());
                    tMap.addColumn("benutzer.NAME", new String());
                    tMap.addColumn("benutzer.VORNAME", new String());
        }

Can you please put a debug message into this method to see if it is called
?
If yes, can you replace the line

dbMap = Torque.getDatabaseMap("nameOfYourDefaultDb");

by

Torque.getDatabaseMap(Torque.getDefaultDb());

and see if it changes anything ?

If this does not change anything, can you print the contents of the
database map at the end of the method ? Then, the table should be there.
Perhaps it disappears again somewhere in between....


Second path of action(if doBuild() in the Map builders is NOT getting
called): I have noticed that in BasePeer.getMapBuilder(String), all
exceptions are caught and NOT rethrown; only a log message is written. Do
you have a Torque logfile ? If yes, does it contain an error message like

BasePeer.MapBuilder failed trying to instantiate.....

If you have no log file, can you put a system.out.println in the catch
block in BasePeer.getMapBuilder(String) and see if it runs into this.

    Thomas


Vlada Djurovic <vdjurovic@gmail.com> schrieb am 17.06.2005 15:24:46:

> This is what I got:
>
> In static initializer
> Torque initialized
> Map builder initialized
> BasePeer: tableName=patient
> BasePeer: dbName=cardiobip
> DBMap tables: {ID_TABLE=org.apache.torque.map.TableMap@ffd135}
> tableMap==null
> Exception occurred during event dispatching:
>
> Everything seems OK untill I call the tableMap. Looks like no
> tableMaps are added to dbMap, except for ID_TABLE.
> I use only one database, and that's the default.
> >
> >
> >
> > Hi,
> >
> > One quick shot: Do you use more than one database ? Database Maps are
per
> > database, and if the peer does not belong to the default db and you are
> > querying the default db, this problem appears.
> > You can check this by printing
> >
> > Torque.getDatabaseMap(PatientPeer.DATABASE_NAME).
> getTable(PatientPeer.TABLE_NAME)
> >
> > if this is not null, then the table is stored elswhere but not in the
> > default db.
> >
> >
> > But probably this is not the case. So we have to go deeper into it.
> > BasePatientPeer should have a static initializer similar to that:
> >
> >     static
> >     {
> >           NSUNIQUEID = "benutzer.NSUNIQUEID";
> >           NAME = "benutzer.NAME";
> >           VORNAME = "benutzer.VORNAME";
> >           if (Torque.isInit())
> >         {
> >             try
> >             {
> >                 getMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >             }
> >             catch (Exception e)
> >             {
> >                 log.error("Could not initialize Peer", e);
> >             }
> >         }
> >         else
> >         {
> >             Torque.registerMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >         }
> >     }
> >
> > Please put in the following debug messages to isolate the problem
further:
> >
> > static
> > {
> >     NSUNIQUEID = "benutzer.NSUNIQUEID";
> >     NAME = "benutzer.NAME";
> >     VORNAME = "benutzer.VORNAME";
> >     if (Torque.isInit())
> >     {
> >         System.out.println("Torque is initialized");
> >         try
> >         {
> >             getMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >             System.out.println("Map builder initialized");
> >         }
> >         catch (Exception e)
> >         {
> >             log.error("Could not initialize Peer", e);
> >             System.out.println("Could not initialize Peer" +
e.getMessage);
> >         }
> >     }
> >     else
> >     {
> >         System.out.println("Torque is NOT initialized");
> >         Torque.registerMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >     }
> > }
> >
> > and send the output
> >
> >     Thomas
> >
> > > OK, here's what I have so far:
> > > -I recompiled torque-3.1.1, and added this to
> > > BasePeer.doInsert(Criteria,Connection):
> > >
> > > DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
> > >         System.out.println("BasePeer: dbName="+criteria.getDbName());
> > >         dbMap.printTables(); //added this in DatabaseMap to print
tables
> > >         TableMap tableMap = dbMap.getTable(tableName);
> > >         if(tableMap==null)
> > >             System.out.println("tableMap==null");
> > >
> > > And after running the code, this is the output:
> > >
> > > In statis initializer
> > > Peer initialized
> > > BasePeer: tableName=patient
> > > BasePeer: dbName=cardiobip
> > > DBMap tables: {ID_TABLE=org.apache.torque.map.TableMap@49cf9f}
> > > tableMap==null
> > > Exception occurred during event dispatching:
> > > java.lang.NullPointerException
> > >         at
org.apache.torque.util.BasePeer.doInsert(BasePeer.java:666)
> > >         at
org.apache.torque.util.BasePeer.doInsert(BasePeer.java:603)
> > >         at com.euroicc.cardiobip.om.BasePatientPeer.
> > > doInsert(BasePatientPeer.ja
> > > a:228)
> > >         at com.euroicc.cardiobip.om.BasePatientPeer.
> > > doInsert(BasePatientPeer.ja
> > > a:201)
> > >         at com.euroicc.cardiobip.gui.NewPatientDialog.
> > > OKButtonActionPerformed(N
> > >
> > > So, I guess DBMap contains only one table, ID_TABLE and table
> > > 'patient' can not be found.
> > >
> > > But I have no clue what could be causing this. I suppose you are
right
> > > about it being a configuration issue, but what?
> > >
> > > @Raphael:
> > > I tried using object instead of criteria, but it's the same
> > >
> > > ---------------------------------------------------------------------
> > > 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