Announcement Announcement Module
No announcement yet.
Spring Rest + ResultSetExtractor problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Rest + ResultSetExtractor problem

    hi I am implementing rest services using spring 3 and also for data fetching using jdbctemplate.
    Currently i have to fetch a record from customer table based upon a customer id passed.

    For same i have used : jdbcTemplate.query(SqlQueries.SQL_SELECT_CUSTOMER_ BY_TOKEN, new Object[]{customerToken}, new CustomerExtractor());

    CustomerExtractor is a private class implementing ResultSetExtractor

    code snippet:

    private class CustomerExtractor implements ResultSetExtractor<Customer> {

    public Customer extractData(ResultSet rs) throws SQLException,
    DataAccessException {

    Customer customer = null;
    customer = new Customer();
    //populate customer
    return customer;

    PS - customer with provided id may or may not exist.

    Here when I access rest service using web browser , i don;t get valid customer even if customer id sent as pathVariable is correct.
    Upon debugging i found that debug pointer does not go inside the if({} block

    There is nothing wrong in query it works fine in mysql workbench.

    Also I implemented rest client using apacheHttpClient now when i used this test class to test restservice i got valid response from service

    Upon debugging i found that debug pointer goes inside the if({} block

    kindly explain why there is such strange behaviour that when accessed via browser i don't get valid response and when tested via test class I get a valid response.