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 12:35:50 GMT




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


Mime
View raw message