Hello, Inside my mapper, i would like to call a method on one of my classes but I have trouble passing parameters to it... I have the following: <if test="@com.mypackage.utils.MyUtils@userExists(#{user.name}, #{user.department}) == true "> ........ </if> It looks like #{user.name} and #{user.department} are not passed properly. Am i using the right syntax? If I use #{user.name} as part of my select statement, it works fine, but when passed as a parameter above, the userExists method gets the follwoing {Mary=null}. While all I want is "Mary". Looks like i'm not using OGNL syntax correctly. Or maybe OGNL can't interpret #{user.name}??? I tried to use bind as follows: <bind name="userName" value="user.name" /> And then the OGNL would looke like this: <if test="@com.mypackage.utils.MyUtils@userExists(#{userName}, #{user.department}) == true "> Inside my userExists method, i see that "{Mary=null}" is still being passed instead of Mary... Any help is appreciated. Thank you You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
Hi NK, You are mixing OGNL syntax with Parameter binding syntax. Try this instead: On Mon, Feb 10, 2014 at 3:57 PM, nk <[hidden email]> wrote:
Frank D. Martínez M. You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
Yes, thank you, of course... One more question... I have another case where the method below (userExists) doesn't exist in the _parameter object but exists in it's parent. For example if I'm operating on a User object for my current mapper and want to execute a method from the Person object, where User extends Person. It seems that myBatis can't get to the inherited method, is that so? Thanks so much! On Monday, February 10, 2014 5:39:29 PM UTC-5, Frank Martinez wrote:
You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
In Java, static methods are not inherited. On Mon, Feb 10, 2014 at 6:01 PM, nk <[hidden email]> wrote:
Frank D. Martínez M. You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
But my method isn't static... On Monday, February 10, 2014 6:03:39 PM UTC-5, Frank Martinez wrote:
You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
@com.mypackage.utils.MyUtils@userExists is the syntax for static method call if your method is not static, try _parameter.userExists(userName, user.department) == true On Mon, Feb 10, 2014 at 6:07 PM, nk <[hidden email]> wrote:
Frank D. Martínez M. You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
Frank, thanks so much. This works like a charm. Appreciate your help! On Monday, February 10, 2014 6:12:10 PM UTC-5, Frank Martinez wrote:
You received this message because you are subscribed to the Google Groups "mybatis-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
Free forum by Nabble | Edit this page |