You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mybatis currently has the ability to match constructor args declared in mapper xml to constructors in bean classes using the parameter name. This mapping allows mybatis to:
Determine which TypeHandler to use to get each column from the ResultSet [see DefaultResultSetHandler]
Determine which Constructor to invoke with the List of values [see DefaultObjectFactory]
My model classes do not contain the parameter name information (see ParamNameUtil.getParamNames(Constructor)) and I do not have control over these (so can't add annotations etc).
I'd like a change in mybatis to support the same behavior but with the following xml
defaults the javaType for each argument to java.lang.Object
uses the UnknownTypeHandler to read values from the ResultSet
tries to invoke the constructor com.company.Account(Object, Object, Object) and fails with NoSuchMethodException
It would be great if mybatis could look for a single constructor with 3 arguments and determine the types from that. If there were more than one constructor with 3 arguments I think it would be fair for mybatis to throw an exception.
As a workaround I have to specifically tell mybatis the types but I feel this is repeating myself, and that mybatis should be able to use reflection to get the javaTypes
…ry to determine the best matching constructor
- falls back to current behaviour if any ambiguity is detected
- remove setters from immutable `ResultMapping`
…ry to determine the best matching constructor
- falls back to current behaviour if any ambiguity is detected
- remove setters from immutable `ResultMapping`
Mybatis currently has the ability to match constructor args declared in mapper xml to constructors in bean classes using the parameter name. This mapping allows mybatis to:
Eg:
My model classes do not contain the parameter name information (see ParamNameUtil.getParamNames(Constructor)) and I do not have control over these (so can't add annotations etc).
I'd like a change in mybatis to support the same behavior but with the following xml
Unfortunately when I try this mybatis:
javaType
for each argument tojava.lang.Object
UnknownTypeHandler
to read values from theResultSet
com.company.Account(Object, Object, Object)
and fails withNoSuchMethodException
It would be great if mybatis could look for a single constructor with 3 arguments and determine the types from that. If there were more than one constructor with 3 arguments I think it would be fair for mybatis to throw an exception.
As a workaround I have to specifically tell mybatis the types but I feel this is repeating myself, and that mybatis should be able to use reflection to get the
javaType
sThe text was updated successfully, but these errors were encountered: