Announcement Announcement Module
Collapse
No announcement yet.
Retrieve data from different objects - queryForlist Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieve data from different objects - queryForlist

    Hi,

    I am new to Spring. I wanted to know how to retrieve values from different objects. I could make myself more clear with an example.

    Lets say I have a Select query like:

    SELECT * FROM STUDENT WHERE NAME = :name AND ID = :id AND GRADE = :grade.

    A simple JavaBean comprises name, id as variables. Should use the JdbcTemplate.queryForList(String sql, Object[] obj, Class return type) ? Or is there some other method.
    1. If yes, the how should I be passing the bean and the String to the Object array? I tried it the following way :
    Object[] obj = new Object[2];
    Bean obj1 = new Bean();
    String grade = new String("B grade");
    obj[0] = obj1;
    obj[1] = grade;
    But it did not work.
    2. Also how would would the variables be mapped correctly? Is is based on the name?
    2. Also what would the return type be? SHould I be passing the RowMapper class as the return type?

    It would be great if somebody could enlighten me on this.

    THanks a lot in advance.
Working...
X