tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 iBATIS > Basics > Select Parameter Map

Select Parameter Map 

The following example shows using select parameter map. User can map necessary properties to a java map. Note that map properties are substituted in place of ? in SQL in the same order.

File Name  :  

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.ibatis.tests.basic;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bethecoder.tutorials.ibatis.common.Student;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SelectParameterMap {

   @param args
   @throws IOException 
   @throws SQLException 
  public static void main(String[] argsthrows IOException, SQLException {

    Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
    SqlMapClient sqlMapClent = SqlMapClientBuilder.buildSqlMapClient(reader);

    Map dataMap = new HashMap();
    List <Student> studs = (List<Student>sqlMapClent.queryForList("Student.idBetween", dataMap);

    for (Student stud : studs) {

It gives the following output,
Student[2, Raj, Kumar, 18, Reading books, +914444488888]
Student[3, Ram, Prasad, 24, Painting, +918888888888]



Books Recommendation

bl  br