Re: Null values in query parameters

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Sep 23 2009 - 06:03:10 EDT

  • Next message: Eugene R.: "Re: Null values in query parameters"

    Hi Evgeny,

    To address NULL's syntax issues, there are special directives
    "#bindEqual and #bindNotEqual". See "Null Values in Bindings -
    #bindEqual and #bindNotEqual Directives" here:

    http://cayenne.apache.org/doc/scripting-sqltemplate.html

    I can't say I am a big fan of the above solution, and maybe we should
    be smarter in SQLTemplateAction about NULL's in #bind directives. Some
    research is needed here.

    Andrus

    On Sep 23, 2009, at 12:55 PM, Evgeny Ryabitskiy wrote:

    > Hello to everyone!
    >
    > I have a problem with passing null params to SQLTemplate.
    >
    > So.. I put null to params, then perform query and got... bad formed
    > SQL query...
    > I know it's because of how Velocity Engine do merge for templates.
    > I know that I can use construction like this: #bind('valueKey'
    > 'jdbcType' null)
    > But this query is generated and I don't know jdbcType :/
    >
    > Also I don't want to pass (java.lang.String) "null" in parameters or
    > my Java code will be huge.
    >
    > Looks like there is no simple way to force cayenne inserting null in
    > templates. Or I am missing something?
    >
    > Maybe we can add some flag for query SQLTemplate constructor.. like
    > boolean "convertNulls" to allow passing nulls in params without huge
    > template changes
    > ( I mean inserting everywhere #bind('valueKey' 'jdbcType' null) ) ?
    >
    >
    > Best regards,
    > Evgeny Ryabitskiy.
    >



    This archive was generated by hypermail 2.0.0 : Wed Sep 23 2009 - 06:10:35 EDT