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 Jeff cox <Je...@cwindustries.net> on 2003/04/05 21:54:40 UTC

intersect tables or TorqueException: Database insert attempted without anything specified to insert

Hi,
	I had an issue where I was getting the Database insert attempted
without anything specified to insert TorqueException. I scoured the
archives and didn't really find a solution. The situation is that I have
an intersect table consisting of two foreign keys only, where the
combination of those keys being the primaryKey. When I went to insert
data into that table, I got the aformentioned TorqueException.

In the mail archives I found that the xxPeer class if one called any
flavor of the doInsert method they all eventually ended up calling
buildCriteria, which would not use the two keys unless the object was
NOT new.

So I put some thought into why this would be the case. It turns out that
it is only the case for tables that are using some sort of idMethod,
which makes sense. If the object is new, you would want the idMethod to
create the key values and not want them to be set manually.(IMHO that
is... ). So I was able to fix the problem by specifically indicateing
that the intersect tables idMethod was set to none. It should be noted
that I had used idMethod=native as the default idMethod for the
database. Hope this helps people. Since I didn't find a solution in the
archives I thought it a good idea to post what I had discovered. Albiet
difficult to follow I suspect... 

Cheers,

Jeff

P.S. Torque is great... I am new to its usage. I tried to use Castor,
but I had way, way to many problems... everytime I turned around there
was another "thing" that wasn't really supported... I just finally gave
up and went with Torque. Did in 3 days what took 2weeks of debugging in
Castor. So thanks for all the effort...