Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 79998 invoked from network); 18 Aug 2009 04:29:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Aug 2009 04:29:02 -0000 Received: (qmail 54644 invoked by uid 500); 18 Aug 2009 04:29:21 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 54607 invoked by uid 500); 18 Aug 2009 04:29:21 -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 54599 invoked by uid 99); 18 Aug 2009 04:29:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Aug 2009 04:29:21 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Aug 2009 04:29:11 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MdGJX-0005Iz-8b for user-java@ibatis.apache.org; Mon, 17 Aug 2009 21:28:51 -0700 Message-ID: <25018289.post@talk.nabble.com> Date: Mon, 17 Aug 2009 21:28:51 -0700 (PDT) From: pczurak To: user-java@ibatis.apache.org Subject: Re: How Do I Change Schema In-Reply-To: <25008285.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: CZUPET@wsinc.com References: <24948645.post@talk.nabble.com> <16178eb10908122137r2835b3fepadc72f47bdd202ce@mail.gmail.com> <24948782.post@talk.nabble.com> <16178eb10908122152r6a39dbb6id60291aaa0a77cc4@mail.gmail.com> <24948843.post@talk.nabble.com> <16178eb10908130549u7690c2c6wb4c7741cf3503182@mail.gmail.com> <24954424.post@talk.nabble.com> <24955435.post@talk.nabble.com> <25008285.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Thank you for all of your help! I think I will just have 2 sets of XML files, one for Test and one for production, just have to remember to update or change both when something changes. Andy Law wrote: > > > pczurak wrote: >> >> I am sorry, I am very new to iBates, I do not know what this means >> >> "You'll have to make >> $schema$ a property of your parameter object. " >> >> how do I do this, can you point me to an example? >> >> > > > OK. When you hit the iBatis query code, you pass in a 'parameter' object > to the getObject/getList routine of the SqlMapClient... > > e.g. > > Object result = this.getSqlMapClient().queryForObject(statementName, > parameterObject); > > > The SQL statement that corresponds to the 'statementName' is then > extracted and parsed/prepared/run using values from the parameterObject > object. > > So, if the statement said.... > > SELECT name, title, id > FROM person > WHERE person_uid = #accession# > > then this statement gets prepared into > > SELECT name, title, id > FROM person > WHERE person_uid = '?' > > and gets given the argument that results from either calling > parameterObject.getAccession() (if parameterObject is a bean) or > parameterObject.get("accession") (if parameterObject is a Map). > > If you try to do that with namespaces, it will fail because the #varName# > syntax results in an invalid statement when it is prepared > > i.e. > > SELECT name, title, id > FROM #namespace#.person > WHERE person_uid = #accession# > > would get prepared into... > > SELECT name, title, id > FROM '?'.person > WHERE person_uid = '?' > > > which is invalid. > > > iBatis does have another syntax for inserting into statements however > which uses the $varName$ syntax. > > Thus: > > i.e. > > SELECT name, title, id > FROM $namespace$.person > WHERE person_uid = #accession# > > could get prepared into a valid statement. > > In order for this to work, you need to make your parameterObject return a > valid reply when sent the message .getNamespace() or .get("namespace") in > exactly the same way that the accession parameter is filled in. This gets > called before the statement is prepared, so presuming that your > parameterObject reports 'freddy' in response to > parameterObject.getNamespace(), your statement would then be prepared as: > > SELECT name, title, id > FROM freddy.person > WHERE person_uid = '?' > > and then the parameterObject would be asked for the accession argument as > before. > > You should be aware though that this is a "dangerous exercise" as it > potentially opens your application up to SQL injection attacks. You should > NEVER use $varName$ insertion without rigorously checking the value being > inserted. > > Hope that helps. > > Later, > > Andy > -- View this message in context: http://www.nabble.com/How-Do-I-Change-Schema-tp24948645p25018289.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org For additional commands, e-mail: user-java-help@ibatis.apache.org