ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hemant.Kamatgi <Hemant.Kama...@target.com>
Subject RE: how tp pass schema name in a query
Date Fri, 12 Oct 2007 20:11:10 GMT
Thanks indeed!

-----Original Message-----
From: Ole Trenner [mailto:ole.trenner@googlemail.com]
Sent: Friday, October 12, 2007 1:24 PM
To: user-java@ibatis.apache.org
Subject: Re: how tp pass schema name in a query

Hemant.Kamatgi wrote:
> Is there a way
> where I can pass the schema name from out side as a parameter so that we
> can maintain only one map file I mean, say for a query ,  'select * from
> <schema>.employee' where <schema> is a place holder for a value that can
> be configured.


In fact there is. In your sqlmap-config.xml you can define a properties
file:

<properties resource="sqlmapconfig.properties" />


sqlmapconfig.properties looks like this:

schema1=foo
schema2=bar


Then you can use named properties everywhere in your sql mappings:

<select id="sampleSelect" parameterClass="..." resultClass="...">
    select * from ${schema1}.tablename
</select>


Cheers,
Ole.

Mime
View raw message