Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtain formal parameter names using Java reflection #549

Closed
trohovsky opened this issue Jan 12, 2016 · 3 comments
Closed

Obtain formal parameter names using Java reflection #549

trohovsky opened this issue Jan 12, 2016 · 3 comments
Assignees
Labels
enhancement Improve a feature or add a new feature
Milestone

Comments

@trohovsky
Copy link
Contributor

-parameters option for storing formal parameter names to bytecode was added in Java 8 to javac. It would be nice if formal parameter names in mapper classes were obtained by reflection. So, specifying a parameter name by @param annotation wouldn't be required.

Note that other libraries have already started to support this feature, for example Hibernate validator.

@emacarron
Copy link
Member

That is worth looking indeed. Thank you por pointing @trohovsky !

@harawata harawata self-assigned this May 10, 2016
@harawata harawata added the enhancement Improve a feature or add a new feature label May 10, 2016
@harawata harawata added this to the 3.4.1 milestone May 11, 2016
harawata added a commit that referenced this issue May 11, 2016
@harawata
Copy link
Member

harawata commented May 11, 2016

Added a new configuration option useActualParamName.

<settings>
  <setting name="useActualParamName" value="true" />
</settings>

UPDATE : The default value of this option is true, so the above setting is not necessary in most cases.

It would be great if you could try the latest SNAPSHOT !

harawata added a commit that referenced this issue May 17, 2016
…s useful only when the legacy style parameter reference (i.e. #{0}, #{1}, ...) is used.
@NYPD
Copy link

NYPD commented Nov 24, 2016

For anyone that finds this GitHub issue and is using eclipse for development, to enable the "-parameters" options inside eclipse you have to go Window > Preferences > Java > Compiler and then under "Classfile Generation" there is a checkbox called "Store information about method parameters (usable via reflection)".

Was working on jUnit tests for my spring web app where MyBatis was not be able to find my named parameters in the mapper xml file. Then a I finally found this "hidden" checkbox which resolved my issue..

pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
…ual names (i.e. the names in the method signature). To use this feature, 1) the project must be compiled in Java 8 with '-parameters' option and 2) 'useActualParamName' must be set to true in MyBatis configuration.
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
…False is useful only when the legacy style parameter reference (i.e. #{0}, #{1}, ...) is used.
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

No branches or pull requests

4 participants