laredotornado | 3 Jun 2010 23:23
Picon

Possible to get ibatis to throw an exception if not all params are filled in?


Hi,

We're using iBatis 2.3 with Tomcat 6.0.26 (Java 1.6).  We have many queries
where we pass in parameters (e.g. "#company_id#"), similar to 

        <select id="getNightlifeDetailsForHotels"
resultMap="SearchResultSQLMaps.searchResultNightlifeMap"
parameterClass="java.util.Map">
                SELECT vw_attractions_and_activities.* FROM
vw_attractions_and_activities WHERE (propertyid = #company_id#) and
(subcategoryid = 7) ORDER BY name
        </select>

I was wondering if there is a way to get ibatis to throw an exception if not
all the parameters are filled in.  Right now, it just substitutes a "null"
for parameters that are not included.

Here is an example Java method we use to invoke a query ...

	public static Object queryForObject(String newStmtId, Object inputParams)
throws SQLException {
		if (inputParams.getClass() == HashMap.class || inputParams.getClass() ==
Hashtable.class)
			inputParams = preProcessParameters((Map) inputParams);
		return getSqlMapHandle().queryForObject(newStmtId, inputParams);
	}

Thanks, - Dave
--

-- 
(Continue reading)

Chema | 3 Jun 2010 23:42
Picon

Re: Possible to get ibatis to throw an exception if not all params are filled in?

Why dont you perform the parameter checking in you Java method ?

I guess that the definition of the query is not the right place to
manage when throwing Java exceptions

2010/6/3 laredotornado <laredotornado <at> gmail.com>:
>
> Hi,
>
> We're using iBatis 2.3 with Tomcat 6.0.26 (Java 1.6).  We have many queries
> where we pass in parameters (e.g. "#company_id#"), similar to
>
>        <select id="getNightlifeDetailsForHotels"
> resultMap="SearchResultSQLMaps.searchResultNightlifeMap"
> parameterClass="java.util.Map">
>                SELECT vw_attractions_and_activities.* FROM
> vw_attractions_and_activities WHERE (propertyid = #company_id#) and
> (subcategoryid = 7) ORDER BY name
>        </select>
>
> I was wondering if there is a way to get ibatis to throw an exception if not
> all the parameters are filled in.  Right now, it just substitutes a "null"
> for parameters that are not included.
>
> Here is an example Java method we use to invoke a query ...
>
>        public static Object queryForObject(String newStmtId, Object inputParams)
> throws SQLException {
>                if (inputParams.getClass() == HashMap.class || inputParams.getClass() ==
> Hashtable.class)
(Continue reading)

Larry Meadors | 3 Jun 2010 23:51
Picon
Gravatar

Re: Possible to get ibatis to throw an exception if not all params are filled in?

The ibatis project has moved and been renamed.

It is no longer being maintained as an Apache project, but has moved
(along with the development team) here:

http://www.mybatis.org/

Please join us at the new location by joining the mailing list here:

http://groups.google.com/group/mybatis-user

Larry

Gmane