Nathan Maves wrote:
I dont think that this is possible from this direction. Remember that
the sqlmap was just doing a map.get("cust_id") and getting null back
which is the expected behavior.
An easy solution would be to first check if the map entry exists:
if (map.containsKey(keyVal))
param = map.get(keyVal);
else
throw new Exception("Query contains param: " + param.getName() +
"that was not found in map");
On the flip side you might be able to have a check on the @Param to see
if there is actually a var in the sqlmap named that. We dont do that
right now but you could extend IB to do that if you wanted to.
I think we have the best solution right now for most situations.
One way to get around this would be to use an actual class for your
parameter. This way you will get this check by default. And you can be
a bit more type safe.
Thanks for the reply. Adding the above is trivial and provides valuable
feedback to the developer for otherwise tricky to locate problems.
Nathan
On Tue, Oct 20, 2009 at 11:47 PM, Guy Rouillier <[email protected]
<mailto:[email protected]>> wrote:
I'm using the new multiple parameter capability in the latest
version 3 beta. I have a method like this in my mapper Java class:
List<Contact> selectContactType(@Param("aCustId") String aCustId,
@Param("eContactType") Contact.ContactTypeEnum eContactType);
These parameters are used in the WHERE clause. Here is the text
from the XML file:
where
cust_id = #{aCustId, javaType=String, jdbcType=VARCHAR}
and contact_tp_id = #{eContactType.intValue, javaType=int,
jdbcType=VARCHAR}
When I first created this, I had a typo in the XML:
cust_id = #{cust_id}
My application simply reported no data; no errors were logged anywhere.
Since I'm using named parameters in a Java map, shouldn't iBatis be
able to tell that the #{cust_id} value I had specified in the SQL
was not in the map? It then could have logged an error, which would
have greatly assisted in identifying why my app wasn't showing any data.
Thanks.
--
Guy Rouillier
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
<mailto:[email protected]>
For additional commands, e-mail: [email protected]
<mailto:[email protected]>
--
Guy Rouillier
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]