Open GoogleCodeExporter opened 9 years ago
[deleted comment]
[deleted comment]
Issue 413 has been merged into this issue.
Original comment by jeffgbut...@gmail.com
on 14 Oct 2011 at 4:07
Original comment by jeffgbut...@gmail.com
on 14 Oct 2011 at 4:09
We are facing the same issue while migrating from iBatis to myBatis. Since
queryForMap is being used mostly while loading metadata, it requires
significant effort while migrating from iBatis to myBatis.
It would be good if this could be taken up soon.
Original comment by vivek1...@gmail.com
on 30 Nov 2011 at 12:53
Jeff I was having a look at 443 and found this bug by chance. Sorry if you had
already started with it.
Fixed in r4625
Original comment by eduardo.macarron
on 31 Jan 2012 at 9:35
Should it be better to have
} else if (method.isAnnotationPresent(MapKey.class) && Map.class.isAssignableFrom(returnType)) {
Type returnTypeParameter = method.getGenericReturnType();
rather than
} else {
final MapKey mapKeyAnnotation = method.getAnnotation(MapKey.class);
if (mapKeyAnnotation != null && Map.class.isAssignableFrom(returnType)) {
Type returnTypeParameter = method.getGenericReturnType();
Original comment by wong...@gmail.com
on 1 Feb 2012 at 4:08
Maybe I missed something. I only managed to get this form
@Select("select id, name from users where id=1")
Map<Integer, Object> getUsersMap2();
to work when the result set has not more than 1 row or a
TooManyResultsException is thrown. How do I get a bunch of name value pairs
into a map directly?
Original comment by wong...@gmail.com
on 1 Feb 2012 at 4:14
[deleted comment]
[deleted comment]
[deleted comment]
Hi Wongkwl, yep getAnnottion is better.
And yes, that can only work with one record. Note that the record is returned
as a Map. In that case
ID=1
NAME=Pocoyo
So just one record can be retrieved.
To get more than one result the mapper should look like this:
List<Map<Integer, Object>> getAListOfMaps();
Have a look at the updated test in r4627
Original comment by eduardo.macarron
on 1 Feb 2012 at 7:47
I think the test case should be
@Select("select id, name from users where id=1")
Map<**String**, Object> getUserAsAMap();
because the result is a mapping of field name to field value, but not id to
name. By the way, the id to name mapping is, I think, what the reporter wants,
i.e.
1=Pocoyo
but not what you said
ID=1
NAME=Pocoyo
I know this is quite difficult to achieve but it makes things nice.
Original comment by wong...@gmail.com
on 1 Feb 2012 at 7:53
Right, that should a String instead of an Integer, that was a bad copy & paste.
And you are right also, with the issue, I fixed my own bug but not the original
one that I think it is not supported by MyBatis 3 so that will be a feature
request.
Will keep this open and fill a new one to keep track of the solved bug.
Thanks for your help!
Original comment by eduardo.macarron
on 1 Feb 2012 at 8:04
Original issue reported on code.google.com by
Juergen....@gmail.com
on 2 Dec 2010 at 11:48