Re: Passing null values in parameters, part 2 )

From: Evgeny Ryabitskiy (evgeny.ryabitski..mail.com)
Date: Mon Sep 28 2009 - 16:09:26 EDT

  • Next message: Adrian A.: "Re: CM Bug?"

    If I explicitly set JDBC type in bind directive, I get right type (the one
    that I have set explicitly).
    But the point is to not set JDBC type. :)
    I believe that Cayenne is able to solve this problem.

    Set whole result is a solution but also not so flexible. If I have select
    from 10 columns and want change type of only one column I should pass all 10
    types (where 9 is same that returns by default).

    I wish to have ability to optionally set result type for several columns
    from API.
    I have very simple idea: To have standard Object-wrapper (name like
    "BindValue" or something like that) that contains reference to Object (or
    null) and it's JDBC type and precision.
    After we touch BindDirective to work with this "BindValue", we can anytime
    pass BindValue and explicitly set JDBC type through API.

    I think it's very useful. Any new opportunity can't make things worse.

    Best regards,
     Evgeny Ryabitskiy.

    2009/9/28 Andrus Adamchik <andru..bjectstyle.org>

    > Yeah, seems like a JDBC driver issue having hard time guessing the type of
    > the result (which Cayenne takes from ResultSetMetadata). So just to
    > doublecheck, if you do #bind($MyNumericColumn 'int'), it doesn't make a
    > difference?
    >
    > As for the solution if nothing works, Cayenne 3.0 has an ability to set
    > explicit result mapping via API:
    >
    >
    > http://cayenne.apache.org/doc/api/org/apache/cayenne/query/SQLTemplate.html#setResult(org.apache.cayenne.map.SQLResult)<http://cayenne.apache.org/doc/api/org/apache/cayenne/query/SQLTemplate.html#setResult%28org.apache.cayenne.map.SQLResult%29>
    >
    > Not sure 100% if it solves this problem, but let's check things one step at
    > a time...
    >
    > Andrus
    >
    >
    > On Sep 28, 2009, at 5:58 PM, Evgeny Ryabitskiy wrote:
    >
    >> Hello to everyone!
    >>
    >> After previous fix I can pass null values in parameters to SQLTemplates.
    >> It's working and it's cool!
    >>
    >>
    >> Now I have one more issue... :
    >>
    >> Here is query (very simple.. to focus on this issue, that I can't
    >> avoid by changing SQL or add directives like #bind or #result)
    >>
    >> SELECT isnull(#bind($MyNumericColumn), AnotherNumericColumn) AS
    >> MyColumn FROM MyTable
    >>
    >> If I pass some not null Decimal value it's working properly and
    >> returns BigDecimal value.
    >>
    >> But if I pass null or not pass anything.. it's still working! but
    >> return type is java.lang.String .. course null now has special JDBC
    >> type for it and JDBC converts my Numeric to String.
    >>
    >> I have only one idea: pass JDBC type with my null in parameters
    >> (like special class "JDBCTypedNull" with constructor and pass there
    >> JDBC type or value type and map it to JDBC).
    >>
    >> Any other suggestions?
    >>
    >> Best regards,
    >> Evgeny Ryabitskiy.
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Mon Sep 28 2009 - 16:09:39 EDT