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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

laredotornado
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Jose María Zaragoza
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 <[hidden email]>:

>
> 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
> --
> View this message in context: http://old.nabble.com/Possible-to-get-ibatis-to-throw-an-exception-if-not-all-params-are-filled-in--tp28773130p28773130.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Larry Meadors
In reply to this post by laredotornado
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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...