emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

@Many without column specified is silently ignored (doesn't execute) #91

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?
3.0.2GA

Please describe the problem.  Unit tests are best!
@Many does not appear to be working as expected.  I have attached a zip
file with the eclipse project zip and a zip of referenced libs. It includes
junit tests. The one failing the assertion in the problem I am experiencing.

What is the expected output? What do you see instead?
I expect that the roleAdopted property in the AuthorizedUser object would
be set with a valid List<Role> object after executing the getUserByUserName
method.  What I am see is a null for this property.

Please provide any additional information below.

Original issue reported on code.google.com by jim.d.ba...@gmail.com on 31 Aug 2010 at 5:49

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry it took me so long to get to look at this, especially given this result...

You're not going to believe this, but it was a simple error.  

Anyway, here it is.

You have this mapping:

  @Result(property="rolesAdopted", javaType=List.class, many=@Many(select="getUserRolesByUserName"))

Which is supposed to call:

  List<Role> getUserRolesByUserName(String userName); 

However, look at your mapping.  Ask:  "What gets passed into the userName 
parameter?"

There's nothing specified.  MyBatis specifies this with the column parameter of 
the Result annotation (same as in XML).

  @Result(property="rolesAdopted", javaType=List.class, column="username" many=@Many(select="getUserRolesByUserName"))

It's not a bug in the @Many functionality so to speak, but perhaps just really 
uninformative.  I'll have to look into decide if there should have been a 
better warning.  (It seems like it on the surface, but it might be that it's 
defaulting for the parameter).

Subject changed to match.

Original comment by clinton....@gmail.com on 5 Sep 2010 at 2:27

GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 5 Feb 2012 at 1:54

GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 5 Feb 2012 at 1:55

GoogleCodeExporter commented 9 years ago
Seems to be the same case as #4. Please test this with latest snapshot.

Original comment by eduardo.macarron on 6 Feb 2012 at 11:19