[
http://issues.apache.org/jira/browse/IBATIS-128?page=comments#action_65118 ]
Jerome Lacoste commented on IBATIS-128:
---------------------------------------
Brandon, I posted the message a little bit late and frustrated and I remembered
about the out of spec overloading after I left...
But still:
- iBatis could detect the problem really easily in ClassInfo. By finding out
that an entry already exists in the HashMap.
if (setMethods.get(name) != null) {
// log a warning. An exception would break existing code...
}
What do you think? Too corner a case to add this check?
- I overloaded the set to overcome an issue I had with iBatis when I started
using it. I wanted to store a Set in the featureIDs properties but iBatis
returned a List from a separate query. So I overloaded the method to make
iBatis happy. I didn't know the javaType argument in the SqlMap config at that
time.
- regarding naming convention, do you mean "featureIDs"? I take a little
liberty with the naming convention when using acronyms which I don't consider
acronyms to be usual words. Most of the time they represent the first letters
of a list of words, which should be capitalized according to Sun specs. ID is a
special case of acronym indeed. But that makes reading easier (for me). But
that's a personal preference... :)
> ClassInfo does not support overloaded methods (e.g. setters)
> ------------------------------------------------------------
>
> Key: IBATIS-128
> URL: http://issues.apache.org/jira/browse/IBATIS-128
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.0.8
> Environment: iBatis 2.0.7
> Reporter: Jerome Lacoste
>
> ClassInfo keys setters by their names.
> private void addMethods(Class cls) {
> Method[] methods = cls.getMethods();
> for (int i = 0; i < methods.length; i++) {
> String name = methods[i].getName();
> if (name.startsWith("set") && name.length() > 3) {
> if (methods[i].getParameterTypes().length == 1) {
> name = dropCase(name);
> --> setMethods.put(name, methods[i]);
> setTypes.put(name, methods[i].getParameterTypes()[0]);
> }
> See
> http://cvs.sourceforge.net/viewcvs.py/ibatisdb/ibatis-dbl-2/src/com/ibatis/common/beans/ClassInfo.java?rev=1.8&view=markup
> So if you overload a method in your bean, you never know which one is going
> to be stored last in the map.
> With:
> public void setFeatureIDs(Set featureIDs) {
> this.featureIDs = featureIDs;
> }
> public void setFeatureIDs(List featureIDs) {
> this.featureIDs = new TreeSet(featureIDs);
> }
> I end up with the following error:
> Error setting property 'setFeatureIDs(java.util.Set=[2] $Proxy4 implements
> interface java.util.List)' of 'Part-20021'. Cause:
> java.lang.IllegalArgumentException: argument type mismatch Caused by:
> java.lang.IllegalArgumentException: argument type mismatch];
> See issue IBATIS-127 for debugging
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira