db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Stenerud <k...@zergsoft.com>
Subject Re: Web Applications
Date Fri, 30 Jan 2004 01:58:51 GMT
I'm having a problem using torque for a simple database.
When I try to save new rows into the database, Torque dies with an exception.
I'm simply creating a torque object and then calling save() on it since the table itself has
only the primary key.
I'm using the id broker so I shouldn't have to set anything on the object at all, right?


My schema file:
---------------------------------------------------------------------
<database
    name="imagedb"
    defaultJavaNamingMethod="javaname"
    defaultIdMethod="idbroker">
...
  <table name="Image" description="An image">
    <column
        name="imageId"
        required="true"
        primaryKey="true"
        type="INTEGER"
        description="Unique ID"/>
  </table>
</database>
---------------------------------------------------------------------


The code in question:
---------------------------------------------------------------------
public class ImagePersistence {
...
    public int addImage() {
...
        Image image = new Image();
        image.save();  // <-- dies here
...
    }
}
---------------------------------------------------------------------


The exception thrown:
---------------------------------------------------------------------
Caused by: org.apache.torque.TorqueException: Database insert attempted without anything specified
to insert
        at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:691)
        at com.somewhere.imagedb.data.BaseImagePeer.doInsert(BaseImagePeer.java:209)
        at com.somewhere.imagedb.data.BaseImagePeer.doInsert(BaseImagePeer.java:551)
        at com.somewhere.imagedb.data.BaseImage.save(BaseImage.java:483)
        at com.somewhere.imagedb.data.BaseImage.save(BaseImage.java:447)
        at com.somewhere.imagedb.data.BaseImage.save(BaseImage.java:427)
        at com.somewhere.imagedb.data.ImagePersistence.addImage(ImagePersistence.java:21)
        ... 46 more
---------------------------------------------------------------------



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