@SuppressWarnings("unchecked")
	@Override
	public <E> int batchInsert(final Class<E> entityType, final Stream<E> entities,
			final InsertsCondition<? super E> condition) {
		@SuppressWarnings("rawtypes")
		EntityHandler handler = this.getEntityHandler();
		if (!handler.getEntityType().isAssignableFrom(entityType)) {
			throw new IllegalArgumentException("Entity type not supported");
		}

		try {
			TableMetadata metadata = handler.getMetadata(this.transactionManager, entityType);
			SqlContext context = handler.createBatchInsertContext(this, metadata, entityType);
			context.setSqlKind(SqlKind.BATCH_INSERT);

			// IDアノテーションが付与されたカラム情報を取得する
			MappingColumn[] idColumns = MappingUtils.getIdMappingColumns(entityType);

			setGeneratedKeyColumns(context, idColumns, metadata);

			int count = 0;
			List<E> entityList = new ArrayList<>();
			for (Iterator<E> iterator = entities.iterator(); iterator.hasNext();) {
				E entity = iterator.next();

				if (!entityType.isInstance(entity)) {
					throw new IllegalArgumentException("Entity types do not match");
				}

				entityList.add(entity);

				handler.setInsertParams(context, entity);
				context.addBatch();

				if (condition.test(context, context.batchCount(), entity)) {
					count += Arrays.stream(doBatchInsert(context, handler, entityList, idColumns)).sum();
					entityList.clear();
				}
			}
			return count + (context.batchCount() != 0
					? Arrays.stream(doBatchInsert(context, handler, entityList, idColumns)).sum()
					: 0);
		} catch (SQLException e) {
			throw new EntitySqlRuntimeException(SqlKind.BATCH_INSERT, e);
		}
	}
@ SuppressWarnings ( "unchecked" ) @ Override public < E > int batchInsert ( final Class < E > entityType , final Stream < E > entities , final InsertsCondition < ? super E > condition ) { @ SuppressWarnings ( "rawtypes" ) EntityHandler handler = this . getEntityHandler ( ) ; if ( ! handler . getEntityType ( ) . isAssignableFrom ( entityType ) ) { throw new IllegalArgumentException ( "Entity type not supported" ) ; } try { TableMetadata metadata = handler . getMetadata ( this . transactionManager , entityType ) ; SqlContext context = handler . createBatchInsertContext ( this , metadata , entityType ) ; context . setSqlKind ( SqlKind . BATCH_INSERT ) ; MappingColumn [ ] idColumns = MappingUtils . getIdMappingColumns ( entityType ) ; setGeneratedKeyColumns ( context , idColumns , metadata ) ; int count = 0 ; List < E > entityList = new ArrayList < > ( ) ; for ( Iterator < E > iterator = entities . iterator ( ) ; iterator . hasNext ( ) ; ) { E entity = iterator . next ( ) ; if ( ! entityType . isInstance ( entity ) ) { throw new IllegalArgumentException ( "Entity types do not match" ) ; } entityList . add ( entity ) ; handler . setInsertParams ( context , entity ) ; context . addBatch ( ) ; if ( condition . test ( context , context . batchCount ( ) , entity ) ) { count += Arrays . stream ( doBatchInsert ( context , handler , entityList , idColumns ) ) . sum ( ) ; entityList . clear ( ) ; } } return count + ( context . batchCount ( ) != 0 ? Arrays . stream ( doBatchInsert ( context , handler , entityList , idColumns ) ) . sum ( ) : 0 ) ; } catch ( SQLException e ) { throw new EntitySqlRuntimeException ( SqlKind . BATCH_INSERT , e ) ; } }
{@inheritDoc}

@see jp.co.future.uroborosql.AbstractAgent#batchInsert(Class, Stream, jp.co.future.uroborosql.SqlAgent.InsertsCondition)