Keys set as autoincremented are ??incorrectly?? set to
TableMap.IDBROKERTABLE instead of TableMap.AUTOINCREMENT when
using a MySQL database. This caused doInsert(Staff) to fail as
below when the IDBroker tables have not been set up.

        Exception:  java.lang.reflect.InvocationTargetException
        Stack Trace follows:
        java.lang.reflect.InvocationTargetException:
java.lang.NullPointerException
        at
org.apache.turbine.om.peer.BasePeer.doInsert(BasePeer.java:712)
        at
org.apache.turbine.om.peer.BasePeer.doInsert(BasePeer.java:615)
        at
org.apache.turbine.om.peer.StaffPeer.doInsert(StaffPeer.java:49)
        at
org.apache.turbine.om.peer.StaffPeer.doInsert(StaffPeer.java:131)
        at
org.takashie.modules.actions.NewStaff.doAdd(NewStaff.java:35)
        etc.

For some reason, IDBroker didn't change any fields in either the
Turbine database or the database my app is using. I would have
thought that IDBroker would keep track of ids that it issues and
update the database accordingly.

Fix that worked for me was to change the torque templates and
regenerate the torque stuff. Here is a patch ...

--- 
/home/guido/java-apache/tdk/share/conf/torque/templates/om/MapBuilder.vm
       Fri Nov 17 02:15:26 2000
+++ ../torque/templates/om/MapBuilder.vm        Tue Dec 26
04:23:58 2000
@@ -76,7 +76,11 @@
         tMap.addForeignPrimaryKey ( get${tfc}_${cfc}(), 
$tstrings.getType( $col.Type ) , "$col.RelatedTableName" ,
"$col.RelatedColumnName" 
);
       #else
         tMap.addPrimaryKey ( get${tfc}_${cfc}(),
$tstrings.getType( 
$col.Type ) );
+       #if($col.isAutoIncrement())
+        tMap.setPrimaryKeyMethod(TableMap.AUTOINCREMENT);
+       #else
         tMap.setPrimaryKeyMethod(TableMap.IDBROKERTABLE);
+       #end
       #end
     #else
       #if($col.isForeignKey())


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to