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

Entity Select Parameter Map 

The following example shows using select parameter map. It lets the user to map properties from a java object. Note that map properties are substituted in place of ? in SQL in the same order.

File Name  :  
/IBATIS001/config/basic/SelectParameterMap2.xml 

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

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;

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 SelectParameterMap2 {

  /**
   @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);

    Student student = new Student();
    student.setFirstName("Ram");
    student.setLastName("Prasad");
    
    student = (StudentsqlMapClent.queryForObject("Student.getByName", student);
    System.out.println(student);
  }
}
   

It gives the following output,
Student[3, Ram, Prasad, 24, Painting, +918888888888]



 
  


  
bl  br