ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meindert" <meind...@pastelebusiness.com>
Subject RE: Configurable static parameters in SQL
Date Fri, 30 Mar 2007 11:25:29 GMT
Not to sure why it doesn't work in your code, I have the following in my


Now() to be used if database is MySql and getDate() if database is Sql

And have no issues using ${nowfunction} in my queries
      ModificationDate = ${nowfunction}
    WHERE Id = #id#

What statement do you see in your log?

I also use dbtype=mssql in my properties and fetch database specific queries
in sql-map-config.xml with;
<sqlMap resource="com/persistence/sqlmapdao/sql/${dbtype}_queries.xml"/>

-----Original Message-----
From: Ilya Boyandin [mailto:Ilya.Boyandin@fh-joanneum.at] 
Sent: 30 March 2007 12:44 PM
To: user-java@ibatis.apache.org
Subject: Configurable static parameters in SQL


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?

Thanks a lot in advance

View raw message