Shawn,
Try this:
<table name="DIARY" idMethod="idbroker">
<column name="DIARY_ID" required="true" primaryKey="true"
type="INTEGER" autoIncrement="true"/>
Gabriel
"Storoe, Shawn" wrote:
>
> Hello,
>
> I am trying to insert records on my page into a simple database table
> that I have generated with the following xml schema using torque.
>
> <!--
> ==================================================================== -->
> <!--
> -->
> <!-- T U R B I N E P R O J E C T S C H E M A
> -->
> <!--
> -->
> <!--
> ==================================================================== -->
> <!-- This is the schema for the DiarEntry Database
> -->
> <!--
> ==================================================================== -->
> <database>
> <table name="DIARY">
> <column name="DIARY_ID" required="true" primaryKey="true"
> type="INTEGER"/>
> <column name="TITLE" size="255" type="VARCHAR"/>
> <column name="AUTHOR" size="255" type="VARCHAR"/>
> <column name="YEAR" size="255" type="VARCHAR"/>
> <column name="MONTH" size="255" type="VARCHAR"/>
> <column name="DAY" size="255" type="VARCHAR"/>
> <column name="TEXT" size="2000" type="VARCHAR"/>
> </table>
> </database>
>
> This is just a test, but I am trying to inser a record and not have to
> set the id myself.
>
> I thought that the IDBroker service would just work and the id would be
> autoincremented, but I keep getting an error that says I can not insert
> null into the primary key.
>
> So I looked in the docs and I saw this
>
> For example if you wish to set up the MapBuilder to take advantage of an
> auto-incrementing Primary Key, you can change the entry in your
> MapBuilder class from;
>
> tMap.setPrimaryKeyMethod(TableMap.IDBROKERTABLE);
> to
>
> tMap.setPrimaryKeyMethod(TableMap.AUTOINCREMENT);
>
>
>
> I tried this and I had the same result.
>
>
>
> I am using the following code to inser my form...
>
> Diary diary = new Diary();
> data.getParameters().setProperties(diary);
> DiaryPeer.doInsert(diary);
>
> And my velocity page has the following on it.
>
> #formCell ("Title" "Title" "")
> </tr>
> <tr>
> #formCell ("Author" "Author" "")
> </tr>
> <tr>
> #formCell ("Year" "Year" "")
> </tr>
> <tr>
> #formCell ("Month" "Month" "")
> </tr>
> <tr>
> #formCell ("Day" "Day" "")
> </tr>
> <tr>
> #formArea ("Text" "Text" "" "10")
> </tr>
> <tr>
>
> which match what the peer class is expecting.
>
> Additionally, I tried to add a DiaryId field to the page and as long as
> I set it correctly, no duplicates, the record gets inserted just fine.
>
> Any help would be greatly appreciated.
>
> Thanks
>
> Shawn
>
>
>
> ------------------------------------------------------------------------
> Name: winmail.dat
> winmail.dat Type: Notepad File (application/ms-tnef)
> Encoding: base64
>
> ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]