Results 1 to 3 of 3

Thread: SimpleIbatisItemWriter in my project

  1. #1
    Join Date
    May 2008
    Location
    Seoul, South Korea
    Posts
    13

    Default SimpleIbatisItemWriter in my project

    Hello.

    In my project, I wrote SimpleIbatisItemWriter class as following.

    Code:
    import org.springframework.batch.item.AbstractItemWriter;
    import org.springframework.orm.ibatis.SqlMapClientTemplate;
    
    import com.ibatis.sqlmap.client.SqlMapClient;
    
    public class SimpleIbatisItemWriter extends AbstractItemWriter{
    
        private String writingQueryId;
        private SqlMapClientTemplate sqlMapClientTemplate;		
    	
    	public void write(Object arg0) throws Exception {
    		sqlMapClientTemplate.insert(writingQueryId,arg0);
    	}
    	
        public void setWritingQueryId(String writingQueryId){
            this.writingQueryId = writingQueryId;
        }
    
        public void setSqlMapClient(SqlMapClient sqlMapClient){
            sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);
        }
    }


    As you see, It is similar to IbatisKeyCollector in structure.

    I am wondering whether this class has potential problems or not.

    I guess this class can be used frequently like IbatisKeyCollector, if it has no problem.

  2. #2

    Default

    Your implementation looks OK.

    Spring Batch doesn't provide database ItemWriters given the argument that the standard Spring *DaoSupport classes provide sufficient support for implementing your own. I don't think it's a great idea because people end up implementing the same easy-to-write ItemWriters over and over again, but that's the way it is for now.

  3. #3
    Join Date
    May 2008
    Location
    Seoul, South Korea
    Posts
    13

    Default

    Thank you for your reply. It's helpful to me

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •