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

Less Than 

The following example shows getting student records who's age less than specified value. The attribute parameterClass="int" allows us to pass student age as parameter which would substitute #value# in the SQL. Since SQLMap is an XML document the symbols <, >, etc. cannot be used directly. We need to embed such symbols inside <![CDATA[ ]]>

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

File Name  :  
com/bethecoder/tutorials/ibatis/tests/basic/LessThan.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.ibatis.tests.basic;

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

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

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

    List <Student> studs = (List<Student>
      sqlMapClent.queryForList("Student.ageLessThan"25);

    for (Student stud : studs) {
      System.out.println(stud);
    }    
  }
}
   

It gives the following output,
Student[2, Raj, Kumar, 18, Reading books, +914444488888]
Student[3, Ram, Prasad, 24, Painting, +918888888888]
Student[5, Vishal, Pratap, 19, Cricket, +91666666666]


                    Print

   



Books Recommendation

 
 
bl  br