db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Schneider <bschnei...@vecna.com>
Subject Re: Error: Database insert attempted without anything specified to insert
Date Sun, 27 Apr 2003 17:48:27 GMT
Daniel,

First you need to set idMethod="native" or idMethod="idbroker" at the
<database> level, in order for autoIncrement="true" to have any effect.

Second, you only want locId (the autoIncrement column) to be your primary
key.  locName should not also be a primary key.  You should specify
unique/not-null constraints and indexes for locName separately, if
appropriate.

I recall that Torque will try to auto-increment any column that is
designated "primaryKey" regardless of the "autoIncrement" attribute.  So
there could be problems if Torque was trying to auto-increment your locName
column.  (Not sure if that's still the case.)

-- Bill

----- Original Message -----
From: "Daniel Rodriguez Millan" <daniel.rodriguez@esencialsistemas.com>
To: <torque-user@db.apache.org>
Sent: Sunday, April 27, 2003 5:46 AM
Subject: Error: Database insert attempted without anything specified to
insert


> Im getting the exception:
>
> org.apache.torque.TorqueException:Database insert attempted without
> anything specified to insert
>
> with my first torque application
>
> Could someone explain me why this exception may be raised?
>
> My relevant data are:
>
> Mysql db:
>
>
>     <table name="loc"
>         javaName="Loc">
>         <column
>             name="locId"
>             required="true"
>             primaryKey="true"
>             type="INTEGER"
>             autoIncrement="true"
>             javaName="locId"/>
>         <column
>             name="locName"
>             required="true"
>              primaryKey="true"
>             type="VARCHAR"
>             size="100"
>             javaName="locName"/>
>     </table>
>
> and my code raising the exception:
>
>             try
>                   {
>                         Loc l=new Loc();
>                         l.setlocId(0);
>                         l.setlocName("loc");
>                         LocPeer.doInsert(l);
>                   }
>                   catch (Exception e)
>                   {
>                   System.out.println("Error:"+e);
>                   }
>
> i tried l.setlocName("loc") and then save, without the doInsert call and
> not setting the autoincrement value, but the exception seems to be
> thrown with all tables in my db :-(
>
>
> any help?
>
>
>
> Daniel rodriguez millan
>



Mime
View raw message