Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 56821 invoked from network); 30 Mar 2007 13:23:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Mar 2007 13:23:56 -0000 Received: (qmail 42506 invoked by uid 500); 30 Mar 2007 13:24:00 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 42488 invoked by uid 500); 30 Mar 2007 13:24:00 -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 42477 invoked by uid 99); 30 Mar 2007 13:24:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Mar 2007 06:24:00 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of jeffgbutler@gmail.com designates 64.233.184.237 as permitted sender) Received: from [64.233.184.237] (HELO wr-out-0506.google.com) (64.233.184.237) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Mar 2007 06:23:52 -0700 Received: by wr-out-0506.google.com with SMTP id i23so641553wra for ; Fri, 30 Mar 2007 06:23:31 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=JtctV84SndEKwAWxeQ8jYn3aJBgu4JyKJlKeX79vx0XpwVeMiU4Ez6NXDREiTsUDgeS7Sm7g/cOgG89mglo8k2PMpeMKlX7IH6szCWCoiCjExrxDGRaFQAYtUBt1oBG1RVDF/8MLqAJ32RV3u6bMLLwV8HWVmu2MLTtZr4vaJDA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=rLsELUZ2iQFxqRwtuJJFwrWOAbygDvnbOs4BapeK/pg0wLPiQFnhZoTShioYKZLj6TQjQjtyJjznWL2VQ3MqIzspJXFPdutRbr3zQ5t0CyPT35oHMXGbp2pB3MzbAuhvAisM06lTjLfI3nBXPo+NDNdapuZEa6MgkY9qiep0tMM= Received: by 10.114.177.1 with SMTP id z1mr731208wae.1175261010582; Fri, 30 Mar 2007 06:23:30 -0700 (PDT) Received: by 10.114.72.19 with HTTP; Fri, 30 Mar 2007 06:23:30 -0700 (PDT) Message-ID: Date: Fri, 30 Mar 2007 08:23:30 -0500 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: Configurable static parameters in SQL In-Reply-To: <460CF1A4.3070703@fh-joanneum.at> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_45974_28889551.1175261010493" References: <437852.40488.qm@web60416.mail.yahoo.com> <460CF1A4.3070703@fh-joanneum.at> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_45974_28889551.1175261010493 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline If you are only needing to set the schema, then you could set a default schema on the JDBC connection URL and then avoid the use of schemas completely within your SQL. Jeff Butler On 3/30/07, Ilya Boyandin wrote: > > Hi Seth, > > thanks for the quick answer! > > Yes, it works this way, but it would be much better if I could get rid > of passing the dbOwner parameter and specify it just once in a config > file, because it's static and I need it for every single query. > > The need of the extra parameter makes using objects of the returning > type as query parameters (by setting their properties corresponding to > the primary key), which is very handy, hardly possible. > > Regards, > Ilya > > Seth Helstrip wrote: > > Hey Ilya, > > You can insert dynamic portions into your sql with > > iBatis using the $ syntax. To take your example, > > below you'd use something like... > > > > > > > > > > > > And then supply the String parameter as an object to > > the query from your Java sqlMap. E.g. > > > > Boolean isTrue = (Boolean) queryForObject("isStudent", > > myParameterString); > > > > Hope this helps. > > Seth > > > > --- Ilya Boyandin > > wrote: > > > > > >> I would like to use static parameters that I can set > >> in a config file > >> directly in SQL queries. I need it especially for > >> the MS SQL database > >> owner that I want neither to hard code in SQL nor to > >> pass as a parameter > >> from Java code each time I execute queiries. I tried > >> to define a > >> "dbOwner" setting in properties.config, but it > >> didn't work with the > >> following code: > >> > >> > >> > >> > >> Is it possible in any other way with iBatis? > >> > >> > > > > ------=_Part_45974_28889551.1175261010493 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
If you are only needing to set the schema, then you could set a default schema on the JDBC connection URL and then avoid the use of schemas completely within your SQL.
 
Jeff Butler

 
On 3/30/07, Ilya Boyandin <Ilya.Boyandin@fh-joanneum.at> wrote:
Hi Seth,

thanks for the quick answer!

Yes, it works this way, but it would be much better if I could get rid
of passing the dbOwner parameter and specify it just once in a config
file, because it's static and I need it for every single query.

The need of the extra parameter makes using objects of the returning
type as query parameters (by setting their properties corresponding to
the primary key), which is very handy, hardly possible.

Regards,
Ilya

Seth Helstrip wrote:
> Hey Ilya,
> You can insert dynamic portions into your sql with
> iBatis using the $ syntax.  To take your example,
> below you'd use something like...
>
>
> <sqlMap namespace="Students">
>     <select id="isStudent"
>  resultClass="java.lang.Integer"
> parameterClass="String">
>         SELECT count(*)  FROM $dbOwner$.students
>  WHERE id = #value#
>  </select>  </sqlMap>
>
> And then supply the String parameter as an object to
> the query from your Java sqlMap.  E.g.
>
> Boolean isTrue = (Boolean) queryForObject("isStudent",
> myParameterString);
>
> Hope this helps.
> Seth
>
> --- Ilya Boyandin <Ilya.Boyandin@fh-joanneum.at>
> wrote:
>
>
>> I would like to use static parameters that I can set
>> in a config file
>> directly in SQL queries. I need it especially for
>> the MS SQL database
>> owner that I want neither to hard code in SQL nor to
>> pass as a parameter
>> from Java code each time I execute queiries. I tried
>> to define a
>> "dbOwner" setting in properties.config, but it
>> didn't work with the
>> following code:
>>
>> <sqlMap namespace="Students">
>>    <select id="isStudent"
>> resultClass="java.lang.Integer">
>>        SELECT count(*)  FROM ${dbOwner}.students
>> WHERE id = #value#
>>    </select>  </sqlMap>
>>
>> Is it possible in any other way with iBatis?
>>
>>
>


------=_Part_45974_28889551.1175261010493--