com.home.ln_spring.ch8.dao.jdbc.annotation.InsertContactTelDetail.java Source code

Java tutorial

Introduction

Here is the source code for com.home.ln_spring.ch8.dao.jdbc.annotation.InsertContactTelDetail.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.home.ln_spring.ch8.dao.jdbc.annotation;

import java.sql.Types;
import javax.sql.DataSource;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.BatchSqlUpdate;

/**
 *
 * @author vitaliy
 */
public class InsertContactTelDetail extends BatchSqlUpdate {

    private static final String SQL_INSERT_CONTACT_TEL = "insert into contact_tel_detail(contact_tel_detail_id, contact_id, "
            + "tel_type, tel_number) " + "values(DEFAULT, :contact_id, :tel_type, :tel_number)";

    private static final int BATCH_SIZE = 10;

    public InsertContactTelDetail(DataSource dataSource) {
        super(dataSource, SQL_INSERT_CONTACT_TEL);
        declareParameter(new SqlParameter("contact_id", Types.INTEGER));
        declareParameter(new SqlParameter("tel_type", Types.VARCHAR));
        declareParameter(new SqlParameter("tel_number", Types.VARCHAR));
        setBatchSize(BATCH_SIZE);
    }

}