You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Guillermo Roman <gu...@gmail.com> on 2016/03/10 22:38:26 UTC

Groovy SQL: Stored Procedure Call Not Executing configureStatement Closure

Hi,

I came across this issue while running some test cases on Groovy 2.4.5.

The following code works as expected. If the stored procedure call takes longer than 5 seconds an SQLException will be thrown indicating that the query timed out:

	sql.withStatement { stmt ->
            stmt.queryTimeout = 5
        }

	sql.call("{call Add_User($user.email, $user.password, ${Sql.BIGINT})}")

However, if I pass a closure to the stored procedure call to retrieve the returned values the configureStatement never gets executed and therefore the query timeout value is ignored:

	sql.withStatement { stmt ->
            stmt.queryTimeout = 5
        }

	sql.call("{call Add_User($user.email, $user.password, ${Sql.BIGINT})}”) { ID ->
	    println “Auto generated User ID: $ID"
	}

Is this is a bug in Groovy? or am I doing something wrong?

Regards,
Guillermo Roman

Re: Groovy SQL: Stored Procedure Call Not Executing configureStatement Closure

Posted by John Wagenleitner <jo...@gmail.com>.
Hi Guillermo,

Yes, I think it was a bug.  The call method taking a closure was not
passing the created statement off to the configureStatement closure.  This
should be fixed by https://github.com/apache/groovy/pull/263 and the fix
should be in 2.4.7.

John

On Thu, Mar 10, 2016 at 1:38 PM, Guillermo Roman <
guillermo.roman.dearagon@gmail.com> wrote:

> Hi,
>
> I came across this issue while running some test cases on Groovy 2.4.5.
>
> The following code works as expected. If the stored procedure call takes
> longer than 5 seconds an SQLException will be thrown indicating that the
> query timed out:
>
> sql.withStatement { stmt ->
>             stmt.queryTimeout = 5
>         }
>
> sql.call("{call Add_User($user.email, $user.password, ${Sql.BIGINT})}")
>
> However, if I pass a closure to the stored procedure call to retrieve the
> returned values the configureStatement never gets executed and therefore
> the query timeout value is ignored:
>
> sql.withStatement { stmt ->
>             stmt.queryTimeout = 5
>         }
>
> sql.call("{call Add_User($user.email, $user.password, ${Sql.BIGINT})}”) { ID
> ->
>     println “Auto generated User ID: $ID"
> }
>
> Is this is a bug in Groovy? or am I doing something wrong?
>
> Regards,
> Guillermo Roman
>