Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 8261 invoked from network); 7 May 2007 07:27:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 May 2007 07:27:41 -0000 Received: (qmail 76405 invoked by uid 500); 7 May 2007 07:27:46 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 76225 invoked by uid 500); 7 May 2007 07:27:45 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 76214 invoked by uid 99); 7 May 2007 07:27:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2007 00:27:45 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of G.Ross@ccw.gov.uk designates 194.83.155.67 as permitted sender) Received: from [194.83.155.67] (HELO mx3.ccw.gov.uk) (194.83.155.67) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2007 00:27:38 -0700 Received: from [192.168.24.69] (helo=smtp3.hq.ccw.gov.uk) by mx3.ccw.gov.uk with esmtp (Exim 4.63) (envelope-from ) id 1Hkxcq-0001Mk-UZ for user-java@ibatis.apache.org; Mon, 07 May 2007 08:27:16 +0100 Received: from gwia3.hq.ccw.gov.uk ([192.168.24.78] helo=gwia3.ccw.gov.uk) by smtp3.hq.ccw.gov.uk with esmtp (Exim 4.60) (envelope-from ) id 1Hkxcq-00006G-Sq for user-java@ibatis.apache.org; Mon, 07 May 2007 08:27:16 +0100 Received: from CCW_GWIA3-MTA by gwia3.ccw.gov.uk with Novell_GroupWise; Mon, 07 May 2007 08:24:22 +0100 Message-Id: <463EE2C6020000060008C98E@gwia3.ccw.gov.uk> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Mon, 07 May 2007 08:23:55 +0100 From: "Gordon Ross" To: Subject: How to support read-only fields/paramters Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org (This may not be totally iBatis realated, I'm not sure. Feel free to point me elsewhere) Often when working with objects, you have fields that should never be changed (e.g. an "id" field which is generated by the database). The usual way (as I understand it) that you achieve this, is to specify the parameter value in the objects constructor, and only provide a get() method, with no corresponding set() method (or a final private one so that it can't be over-ridden) However, iBatis does not use the parmaterised constructor to build an object. Instead, it uses the null constructor, and then calls the individual set() methods - which have to be public for iBatis to be able to call them. This means that anyone could call the set() method and change the value. There are two ways that I can see to achieve this: 1) Only allow the set() method to be called once. (Use some internal boolean flag to see if it the set() method has been called before) 2) Somehow configure/change iBatis so that it would use the constructor to set the request fields. Anyone got any thoughts or comments on this ? Thanks, GTG Gordon Ross, Network Manager/Rheolwr Rhydwaith Countryside Council for Wales/Cyngor Cefn Gwlad Cymru