From torque-dev-return-7639-apmail-db-torque-dev-archive=db.apache.org@db.apache.org Mon Dec 18 12:19:48 2006 Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 25677 invoked from network); 18 Dec 2006 12:19:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Dec 2006 12:19:48 -0000 Received: (qmail 60819 invoked by uid 500); 18 Dec 2006 12:19:55 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 60806 invoked by uid 500); 18 Dec 2006 12:19:55 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 60795 invoked by uid 99); 18 Dec 2006 12:19:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Dec 2006 04:19:55 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Dec 2006 04:19:47 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C47BA71428E for ; Mon, 18 Dec 2006 04:19:26 -0800 (PST) Message-ID: <7997714.1166444366801.JavaMail.jira@brutus> Date: Mon, 18 Dec 2006 04:19:26 -0800 (PST) From: "Thomas Fischer (JIRA)" To: torque-dev@db.apache.org Subject: [jira] Commented: (TORQUE-69) Record.save() may not work if there is no primary key but no error is thrown. In-Reply-To: <13280400.1164817404090.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/TORQUE-69?page=comments#action_12459285 ] Thomas Fischer commented on TORQUE-69: -------------------------------------- After discussion on the mailing list whether to maintain field state, the exception seems the only sensible thing to to before the 3.3 release. I'd suggest to always throw an Exception in the Peer's doUpdate(Criteria,connection) method if no primary key exists. > Record.save() may not work if there is no primary key but no error is thrown. > ----------------------------------------------------------------------------- > > Key: TORQUE-69 > URL: http://issues.apache.org/jira/browse/TORQUE-69 > Project: Torque > Issue Type: Bug > Components: Runtime > Affects Versions: 3.3 > Environment: WinXP / Java 1.5 / Tomcat 5.5 / MS SQL > Reporter: CG Monroe > Priority: Minor > > Here's the situation. > You have a table with no primary key. E.g. A table named Poor_Design with columns: FK1, FK2, Value1, Value2. > You then retrieve a record object from that table, modify it, and then save it, e.g. > Criteria c = new Criteria(); > c.add(PoorDesignPeer.FK1, fk1); > c.add(PoorDesignPeer.FK2, fk2); > List result = PoorDesignPeer.doSelect(c); > PoorDesign modifiedRec = (PoorDesign) results.get(0); > modifiedRec.setValue1(newValue); > modifiedRec.save(); > The save() ( UPDATE ) to the DB will not suceed, but no error will be thrown indicating it failed. > This also occur if PoorDesignPeer.doUpdate(modifiedRec) is used. > This condition should probably throw an error in all cases, since there is no reliable way to locate the original record in the DB. > In trying to trace it out, I suspect that there is probably some logic bug in the underlying BasePeer object. This is probably related to the buildcriteria(object) not being able to identify modified fields from unmodified and therefore > creating a criteria for a record that can't be retrieved again at lower levels. But the logic for this is complicated. > However, an easy way to fix this might be to just update the generated peer's doUpdate( object ) method to check for primary keys or not, and throw an exception here all the time. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org