Announcement Announcement Module
No announcement yet.
Trouble with MappingSqlQuery Parameters Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with MappingSqlQuery Parameters


    I've created several MappingSqlQueries for my application, however one doesn't seem to work properly. The only thing that makes it unique is that a single column is used twice in the WHERE clause of the sql string.

    "select id from mytable where receiptTime >= ? and receiptTime < ?"

    When I attempt to execute the query with

    I get no results back no matter what the values exeception is thrown.... mapRow() is just never called.

    If I hardcode integer values into the sql string, remove the myQuery.declareParameter calls re-run it by just calling myQuery.execute(); it works perfectly, with many calls to mapRow(). Moreover, if I remove one of the receiptTime conditions, it works as well.

    I've also tried this query on the mysql commandline just to make sure and it works as expected there. Any ideas?

    Other details...I'm using Spring 1.2.x and MySql 4.0.x

    Thanks in advance,


  • #2
    Do I need to subclass MappingSqlQueryWithParameters instead of MappingSqlQuery? (i.e. is this query a "non-trivial" case?)

    If so can someone provide an example of how to do this as I have been unable to locate one.



    • #3
      I rewrote the code to see if I could get things working as a jdbcTemplate w/ RowCallbackHandler...same results.


      • #4
        If you post your code, maybe someone can spot the problem.


        • #5
          I just located the problem....

          It was my stupid UnitTest not doing proper math to drive the query...

          Spring was on it's best behavior all along.

          Thanks guys!