mybatis / mybatis-3

MyBatis SQL mapper framework for Java
http://mybatis.github.io/mybatis-3/
Apache License 2.0
19.84k stars 12.87k forks source link

Request for adding explanation how to call static methods to MyBatis manual. #871

Open Nobuyuki-Inaba opened 7 years ago

Nobuyuki-Inaba commented 7 years ago

Hi,

I know that you are able to call static methods in My Batis Mapper XML files, but the manual, I think, doesn't explain the way directly. I'm afraid that some of my colleagues had troubled because they don't know that way. Surely, the "Dynamic SQL" page explains like this.

MyBatis employs powerful OGNL based expressions to eliminate most of the other elements

, so it's make sense that you can call static methods using OGNL syntax, but its' not straightforward explanation.

I would like to suggest to add the below explanation to "Mapper XML Files" page. If you'd add the explanation to the page, it would be great.


You can call static methods and refer static fields like this, calling a static method; @class@method(args), e.g.

@org.apache.commons.lang3.StringUtils@isEmpty(data)

refering a static field: @class@field, e.g.

@java.lang.Math@PI

Best regards, Nobuyuki Inaba

kazuki43zoo commented 7 years ago

Hi @Nobuyuki-Inaba, Thanks for your suggestion ! We are welcome your contribution :) Could you contribute for this ?

pagehelper commented 7 years ago

MyBatis OGNL in the tutorial

MyBatis OGNL expressions in common use:

  1. e1 or e2
  2. e1 and e2
  3. e1 == e2,e1 eq e2
  4. e1 != e2,e1 neq e2
  5. e1 lt e2
  6. e1 lte e2, gt,gte)
  7. e1 in e2
  8. e1 not in e2
  9. e1 + e2,e1 * e2,e1/e2,e1 - e2,e1%e2
  10. !e,not e
  11. e.method(args)
  12. e.property
  13. e1[ e2 ]
  14. @class@method(args)
  15. @class@field
kazuki43zoo commented 7 years ago

The OGNL language reference see https://commons.apache.org/proper/commons-ognl/language-guide.html#Appendix:_OGNL_Language_Reference.

zhangkang1521 commented 4 years ago

@org.apache.commons.lang3.StringUtils@isEmpty(data) org.apache.commons.lang3.StringUtils is too long, can any alias to use it? like StringUtils@isEmpty(data) @abel533