You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Karl Stenerud <ka...@zergsoft.com> on 2004/01/30 03:00:13 UTC
Problem with save() method
Sorry, messed up on the message subject :-)
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