db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff cox" <J...@cwindustries.net>
Subject intersect tables or TorqueException: Database insert attempted without anything specified to insert
Date Sat, 05 Apr 2003 19:54:40 GMT
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...





Mime
View raw message