No! #bindEqual can't help me... I am using something like this: INSERT INTO TABLE1 (id, NullableColumn) values (10, $MyNullValue)
And in param MyNullValue I put null, It's legal to insert null in this column. So I can't use #bindEqual here, the only solution to pass (String)"null" as parametr... but I don't wan't to put everywhere in my code such constructions: (paramValue == null) ? "null" : paramValue It is possible to do this check on perform query level.... Going to make some changes to cayenne againg.... Best regards, Evgeny Ryabitskiy. 2009/9/23 Eugene R. <[email protected]>: > No! #bindEqual can't help me... > I am using something like this: > > INSERT INTO TABLE1 (id, NullableColumn) values (10, $MyNullValue) > > And in param MyNullValue I put null, It's legal to insert null in this column. > So I can't use #bindEqual here, the only solution to pass > (String)"null" as parametr... but I don't wan't to put everywhere in > my code such constructions: > (paramValue == null) ? "null" : paramValue > > It is possible to do this check on perform query level.... Going to > make some changes to cayenne againg.... > > Best regards, > Evgeny Ryabitskiy. > > > 2009/9/23 Andrus Adamchik <[email protected]>: >> 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. >>> >> >> >
