[
https://issues.apache.org/jira/browse/GROOVY-8175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15996869#comment-15996869
]
John Wagenleitner commented on GROOVY-8175:
-------------------------------------------
Groovy SQL has support for named and named ordinal parameters which I think
provides a very nice way to bind parameters.
For example:
{code}
def sql = Sql.newInstance(...)
sql.eachRow("select * from some_table where some_col=:someColValue and
some_col2=:someCol2Value", [someColValue:'foo', someCol2Value:'bar']) { row ->
println row
}
{code}
and
{code}
def sql = Sql.newInstance(...)
sql.eachRow("select * from some_table where some_col=?1.someColValue and
some_col2=?2.someColValue", [someColValue:'foo'], [someColValue:'bar']) { row ->
println row
}
{code}
Is there something about the MyBatis syntax that is missing with what's
currently available or is it about being able to also support that syntax in
addition to what's currently available?
> MyBatis-like binding variable for GroovySql
> -------------------------------------------
>
> Key: GROOVY-8175
> URL: https://issues.apache.org/jira/browse/GROOVY-8175
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
>
> As the code shows, we can bind variables elegantly.
> {code}
> def sql = Sql.newInstance(...)
> sql.eachRow("select * from some_table where some_col=#{someColValue} and
> some_col2=#{someCol2Value}", [someColValue:'foo', someCol2Value:'bar']) { row
> ->
> println row
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)