Saturday, September 27, 2014

Ibatis Sample caching

package Ibatis;

import java.util.List;
import org.apache.log4j.Logger;
import org.junit.Test;

import com.kcing.kailas.ibator.dao.model.Custmr;

import static org.junit.Assert.*;


public class TestIbatisCaching {

    // @Test
   
   

    public void testIbatisCaching() {
       
       
       
       
        Logger logger = Logger.getLogger(this.getClass());
        try {
            System.out.println("abishkar");
            // repeated queries
            for (int i = 0; i < 5; i++) {
                List<Custmr> custmr = SqlMapConfig.getSqlMap().queryForList("CUSTMR.ibatorgenerated_selectByExample");

                // check if it's null
                assertNotNull(custmr);

                // sleep
               
                Object o = new Object();
                synchronized (o) {
                    o.wait(2000);
                }

                for (Custmr contoh : custmr) {
                    logger.debug(contoh.getCsdhtl());
                }

                logger.debug("================================");
            }
        } catch (Exception ex) {
            logger.error(ex);
        }
    }

   
    public static void main(String[] args) {
        TestIbatisCaching test = new TestIbatisCaching();
        test.testIbatisCaching();
    }
}

No comments:

Post a Comment