class MarriageDocumentTypeRepository {

	public void create(List<MarriageDocumentType> marriageDocumentTypes) {
		log.debug("MarriageDocumentTypes: " + marriageDocumentTypes);

		final String sql = MarriageDocumentTypeQueryBuilder.BATCH_INSERT_QUERY;
		final String tenantId = marriageDocumentTypes.get(0).getTenantId();
		final int batchSize = Integer.parseInt(serviceConfigurationService
				.getServiceConfigValueByKeyAndTenantId(ServiceConfigurationKeys.MARRIAGEBATCHSIZE, tenantId)
				.toString());
		log.debug("Batch Size :: " + batchSize);
		for (int j = 0; j < marriageDocumentTypes.size(); j += batchSize) {

			final List<MarriageDocumentType> batchList = marriageDocumentTypes.subList(j,
					j + batchSize > marriageDocumentTypes.size() ? marriageDocumentTypes.size() : j + batchSize);

			jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {

				@Override
				public void setValues(PreparedStatement ps, int index) throws SQLException {
					final MarriageDocumentType marriageDocumentType = marriageDocumentTypes.get(index);
					ps.setLong(1, marriageDocumentType.getId());
					ps.setString(2, marriageDocumentType.getName());
					ps.setString(3, marriageDocumentType.getCode());
					ps.setBoolean(4, marriageDocumentType.getIsActive());
					ps.setBoolean(5, marriageDocumentType.getIsIndividual());
					ps.setBoolean(6, marriageDocumentType.getIsRequired());
					ps.setString(7, marriageDocumentType.getProof().toString());
					ps.setString(8, marriageDocumentType.getApplicationType().toString());
					ps.setString(9, marriageDocumentType.getTenantId());
				}

				@Override
				public int getBatchSize() {
					return marriageDocumentTypes.size();
				}
			});
		}
	}

}