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 Noel Murphy <bn...@rogers.com> on 2006/08/18 20:57:53 UTC
Can't save object that has no fields except primary key
I have a database schema which has one table that has nothing in it
except the primary key field. It is basically just a way of relating
all sorts of other information together.
However, when I try to save one of these objects, I get a
TorqueException.
Database insert attempted without anything specified to insert
I will admit that I'm fairly new to Torque, however my other objects
seems to save alright. In case it matters, I'm using the idBroker way
of generating primary key values.
Any thoughts? Is this a bug?
Excerpt from my schema.xml file:
<table name="person" description="Person entries in the family
tree">
<column name="person_id" required="true" primaryKey="true"
type="INTEGER"
description="Person Id"/>
</table>
Noel Murphy
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Can't save object that has no fields except primary key
Posted by Thomas Vandahl <tv...@apache.org>.
Noel Murphy wrote:
> I will admit that I'm fairly new to Torque, however my other objects
> seems to save alright. In case it matters, I'm using the idBroker way of
> generating primary key values.
That matters indeed. If you declare the column as primaryKey and the
idMethod of the table is "idBroker" you state to Torque that it should
deal with the value of that column. So there is nothing else to save -
which is what the exception says. I cannot believe that this is actually
what you want because you won't be able to find your value again nor
have you any method to access related records.
If you really want to save values of keys in the table described, you
need to define the table as idMethod="none" or remove the column
declaration as primary key.
As a side note: Defining a column as primary key means that the values
in the column must be unique, which is normally assured by an unique
index. Based on this rule I do not understand what your table should do
at all. I suggest to check you database schema again.
Bye, Thomas.
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org