You are mixing up three different idMethods. Oracle uses sequences so
you should be using idMethod="sequence" if you wish to use the native
method. (The sequence and autoincrement options have been combined to
"native", which automatically chooses the appropriate method for a
database, but that may not be in 2.1.)
If you wish to use idbroker, then set idMethod="idbroker" and make sure
an entry for the table exists in the ID_TABLE.
john mcnally
Harvinder Singh wrote:
>
> Hi,
> Please answer to following question.
>
> I am using Oracle 8i data base and using following .xml to generate
> corresponding table schema.
>
> <app-data>
> <database>
> <table name="category" idMethod="autoincrement">
> <column name="category_id" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
> <column name="name" size="100" type="VARCHAR"/>
> </table>
> <table name="item" idMethod="autoincrement">
> <column name="item_id" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
> <column name="name" size="100" type="VARCHAR"/>
> <column name="price" required="true" type="INTEGER"/>
> <column name="category_id" required="true" type="INTEGER"/>
> <foreign-key foreignTable="category">
> <reference local="category_id" foreign="category_id"/>
> </foreign-key>
> </table>
> </database>
> </app-data>
>
> In my peer code i want to insert category_id auto incremented. I am using the
> following code to do it.
> Criteria crit = new Criteria();
> crit.add(CategoryPeer.NAME,"category2");
> CategoryPeer.doInsert(crit);
>
> If i set tMap.setPrimaryKeyMethod(TableMap.IDBROKERTABLE); in
> CategoryMapBuilder.java I get following exception:
> -----------------------------------------------------------------------------
> ---------
> Turbine: Turbine: init() Ready to Rumble!
> Exception in thread "main" java.lang.NullPointerException
> at java.util.Hashtable.get(Hashtable.java:320)
> at org.apache.turbine.util.db.IDBroker.getNextIds(IDBroker.java:358)
> at
> org.apache.turbine.util.db.IDBroker.getIdAsBigDecimal(IDBroker.java:2
> 85)
> at org.apache.turbine.om.peer.BasePeer.doInsert(BasePeer.java:746)
> at org.apache.turbine.om.peer.BasePeer.doInsert(BasePeer.java:657)
> at
> org.apache.turbine.BaseCategoryPeer.doInsert(BaseCategoryPeer.java:11
> 1)
> at org.apache.turbine.Category.main(Category.java:42)
> -----------------------------------------------------------------------------
> ----------------------------
>
> I saw my id_table in oracle which is empty. Do we need to insert first record
> here.
> If i set tMap.setPrimaryKeyMethod(TableMap.AUTOINCREMENT); , even then
> automatic sequence is not generated.
>
> Could you please tell me how to make it working.
>
> Looking forward to yr reply.
>
> Regards,
> Harvinder
>
> -----
> Harvinder Singh
> Associate Consultant,
> Mindtree Consulting Pvt. Ltd.
> Bangalore - 560070
> Ph: 91-80-6545263 to 6545266 ext 1677
> www.mindtree.com
>
> ---------------------------------------------------------------------
> 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]