I'm not suggesting that YOU add an extra column, that was the solution for my problem. I think if you add autoIncrement="true" to your domain column you might have better luck.
-----Original Message----- From: Roy Truelove [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 04, 2002 3:29 PM To: [EMAIL PROTECTED] Subject: RE: Bizarre error inserting a new row (Torque claims that there's no data to ins Hi Andrew, You shouldn't have to do that though.. your two foreign keys taken together should be enough to form your primary key. I could add an arbitrary interger col that autoincrements, but I'd rather not do that when the domain col by itself uniquely identifies the row. Also, after commenting out that "if" statement mentioned earlier, I'm starting to have very strange primary key problems, so I have to put that if back.. This is still a pending problem, if anyone has any ideas. Thanks again, Roy ------------------------- Roy, I think if you make the domain column set to autoIncrement="true" your troubles might be helped. At least that helped for me. The solution to my foreign keys table being that I needed one primary key set to autoincrement, and then my two foreign keys as usual. -A -----Original Message----- From: Roy Truelove [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 02, 2002 11:02 PM To: [EMAIL PROTECTED] Subject: RE: Bizarre error inserting a new row (Torque claims that there's no data to ins I am having the same problem, although with a different type of table that might shed more light on the subject. My table has 1 primary key which is a string; my "domain" column. (The XML is at the bottom of this message.) When I try this : DomainMapperEntry dme = new DomainMapperEntry(); dme.setDomain("someDomain"); dme.save(); I get the error "Invalid argument value: Duplicate entry '' for key 1", meaning that the "domain" column is being set to an empty string, and not to "someDomain". I also tracked this back to the buildCriteria() method in my Peer, and saw that domain will *not* be put in the criteria because primary keys are not included with inserts, only updates. That makes sense for prikeys that are autogenerated by the database, but my key is not autogenerated. I commented out the line : if ( !obj.isNew() ) in the buildCriteria, so that my primary key will always be added.I have not (after *very little* testing) had any trouble; my objects are now being saved. I'm assuming that the if statement does belong there for some reason though, and I'm nervous to leave it out in production. tia for any help, Roy <table name = "Domain_Mapper" javaName = "DomainMapperEntry"> <column name="domain" required="true" primaryKey="true" type="VARCHAR" size="30"/> <column name="company_id" type="INTEGER" /> <column name="autoMapPeople" required="true" type="BIT" default="1" /> <foreign-key foreignTable="Companies"> <reference local="company_id" foreign="company_id"/> </foreign-key> </table> --------------------------- An interesting update. The problem lies in the fact that the table only consists of two foreign keys. The code in buildCriteria() will NEVER add the values for an insert because both table entries are listed as primaryKeys, which in the generated code only get added to criteria on an update. However, one cannot simply not list the columns as primary keys, as this generates compile errors. What's the correct solution to this problem that does not involve always editing the BaseXXXPeer class? -Andrew -----Original Message----- From: Andrew [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 12:22 PM To: Torque Users List (E-mail) Subject: Bizarre error inserting a new row (Torque claims that there's no data to insert) This is happening, currently, to one of my tables. I am doing: ConversationMessageDO om = new ConversationMessageDO(); om.setMessageID("1"); om.setConversationID("2"); om.save(); Those two fields are the only rows on this column. This is an intersect table, and both rows point to other tables, if that helps. When I try to do this I get the following exception thrown at me: org.apache.torque.TorqueException: Database insert attempted without anything sp ecified to insert at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:839) at com.uniti.db.om.BaseConversationMessageDOPeer.doInsert(BaseConversati onMessageDOPeer.java:152) at com.uniti.db.om.BaseConversationMessageDOPeer.doInsert(BaseConversati onMessageDOPeer.java:417) at com.uniti.db.om.BaseConversationMessageDO.save(BaseConversationMessag eDO.java:376) at com.uniti.db.om.BaseConversationMessageDO.save(BaseConversationMessag eDO.java:341) at com.uniti.db.om.BaseConversationMessageDO.save(BaseConversationMessag eDO.java:324) I spent a good deal of time perusing the source code to find out whats up. The last line called in BaseConversationMessageDOPeer calls doInsert on the BasePeer class, as you can see from the trace. The parameters it passes are a Criteria and DBConnection. The interesting bit is that the Criteria seems to be completely empty. Why? Because in buildCriteria() it only ads information to the criteria object if the object is not new. Well the object is of course new since we are doing an insert. Anyone know whats up with this? This doesn't seem to happen with all classes. I am most perplexed. Thanks. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
