Announcement Announcement Module
Collapse
No announcement yet.
SimpleIbatisItemWriter in my project Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


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

      Comment

      Working...
      X