db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trey Long <james_l...@provima.com>
Subject IdBroker, Native and MSSQL
Date Mon, 19 Dec 2005 22:17:53 GMT
Alright Torque Experts.

Using MSSQL and trying to save new rows with defaultIdMethod="native". 
Now I am getting a null pointer exception In the setPrimaryKey method of 
one of the base objects (see excerpt 'stack'). I debugged a little bit 
and found that the variable keyGen was always coming back null. The if 
statements only deal with keyGen not being null, in fact, I don't see 
how keyGen could ever be set to null after the outermost if(keyGen != 
null...). Take a look at the excerpt from BasePeer.class to see what I 
am talking about.

At least there is a little section that seems like it would never be 
thrown thus giving me the NullPointerException. At most there is some 
flaw in the handling of auto-increment PK's in SQL server.

Is there a known issue with autoincrement PK's in MSSQL server? Does 
something come to mind that I am doing wrong?

Excerpt from Stack:
>     [junit] java.lang.NullPointerException
>     [junit]     at 
> com.provima.pcsw.db.gen.base.BaseUnderwritingApp.setPrimaryKey(BaseUnderwritingApp.java:1012)
>     [junit]     at 
> com.provima.pcsw.db.gen.base.BaseUnderwritingAppPeer.doInsert(BaseUnderwritingAppPeer.java:608)
>     [junit]     at 
> com.provima.pcsw.db.gen.base.BaseUnderwritingApp.save(BaseUnderwritingApp.java:982)
>     [junit]     at 
> com.provima.pcsw.db.gen.base.BaseUnderwritingApp.save(BaseUnderwritingApp.java:946)
>     [junit]     at 
> com.provima.pcsw.db.gen.base.BaseUnderwritingApp.save(BaseUnderwritingApp.java:926)
>     [junit]     at 
> com.provima.pcsw.db.test.TestDatabase.testSave(TestDatabase.java:51)
Excerpt from BasePeer.class:
>         IdGenerator keyGen = tableMap.getIdGenerator();
>
>         ColumnMap pk = getPrimaryKey(criteria);
>
>         // If the keyMethod is SEQUENCE or IDBROKERTABLE, get the id
>         // before the insert.
>         if (keyGen != null && keyGen.isPriorToInsert())
>         {
>             // pk will be null if there is no primary key defined for 
> the table
>             // we're inserting into.
>             if (pk != null && 
> !criteria.containsKey(pk.getFullyQualifiedName()))
>             {
>                 if (keyGen == null)
>                 {
>                     throw new TorqueException(
>                             "IdGenerator for table '" + table + "' is 
> null");
>                 }
>
>                 id = getId(pk, keyGen, con, keyInfo);
>                 criteria.add(pk.getFullyQualifiedName(), id);
>             }
>         }
-Jim

---------------------------------------------------------------------
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