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

How to use arrays as parameters? #1

Closed
aadrian opened this issue Mar 5, 2013 · 2 comments
Closed

How to use arrays as parameters? #1

aadrian opened this issue Mar 5, 2013 · 2 comments

Comments

@aadrian
Copy link
Member

aadrian commented Mar 5, 2013

Please give an example how to use arrays as parameters in dynamic sqls.

Looking at "ParenBindVariableNode.java" seems to be possible to use arrays and lists as parameters.

Thanks in advance.

@takezoe
Copy link
Member

takezoe commented Mar 5, 2013

You can use the Array property as IN parameter as same as the List property.

For example, here is the Java code to invoke the SQL file which has an IN parameter:

public static class BookNamesParam {
  public String[] bookNames;
}

BookNamesParam param = new BookNamesParam();
param.bookNames = new String[]{"Mirage in Action", "Essential Mirage" };

List<Book> results = sqlManager.getResultList(
  Book.class,
  SQL_PREFIX + "SqlManagerImplTest_selectByBookNames.sql",
  param);

The SQL file is below:

SELECT BOOK_ID, BOOK_NAME, AUTHOR, PRICE
FROM BOOK
/*IF bookName != null*/
WHERE BOOK_NAME IN /*bookNames*/('Mirage in Action')
/*END*/

@aadrian
Copy link
Member Author

aadrian commented Mar 5, 2013

Thank you very much for the very quick response :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants