11# JSqlServerBulkInsert #
22
3+ [ JSqlServerBulkInsert ] : https://github.com/bytefish/JSqlServerBulkInsert
34[ MIT License ] : https://opensource.org/licenses/MIT
45
56[ JSqlServerBulkInsert] is a library to simplify Bulk Inserts to the SQL Server. It wraps the `` SQLServerBulkCopy `` behind a nice API.
@@ -12,14 +13,22 @@ You can obtain [JSqlServerBulkInsert] from Maven by adding the following:
1213<dependency >
1314 <groupId >de.bytefish</groupId >
1415 <artifactId >jsqlserverbulkinsert</artifactId >
15- <version >1.0 </version >
16+ <version >1.1 </version >
1617</dependency >
1718```
1819
1920## Getting Started ##
2021
2122Imagine `` 1,000,000 `` Persons should be inserted into an SQL Server database.
2223
24+ ### Results ###
25+
26+ Bulk Inserting `` 1,000,000 `` entities to a SQL Server 2016 database took `` 5 `` Seconds:
27+
28+ ```
29+ [Bulk Insert 1000000 Entities] PT4.559S
30+ ```
31+
2332### Domain Model ###
2433
2534The domain model could be the `` Person `` class with a First Name, Last Name and a birth date.
@@ -118,6 +127,7 @@ import de.bytefish.jsqlserverbulkinsert.mapping.AbstractMapping;
118127import de.bytefish.jsqlserverbulkinsert.test.model.Person ;
119128import de.bytefish.jsqlserverbulkinsert.SqlServerBulkInsert ;
120129import de.bytefish.jsqlserverbulkinsert.test.base.TransactionalTestBase ;
130+ import de.bytefish.jsqlserverbulkinsert.test.utils.MeasurementUtils ;
121131import org.junit.Assert ;
122132import org.junit.Test ;
123133
@@ -145,8 +155,11 @@ public class IntegrationTest extends TransactionalTestBase {
145155 PersonMapping mapping = new PersonMapping ();
146156 // Create the Bulk Inserter:
147157 SqlServerBulkInsert<Person > bulkInsert = new SqlServerBulkInsert<> (mapping);
148- // Now save all entities of a given stream:
149- bulkInsert. saveAll(connection, persons. stream());
158+ // Measure the Bulk Insert time:
159+ MeasurementUtils . MeasureElapsedTime(" Bulk Insert 1000000 Entities" , () - > {
160+ // Now save all entities of a given stream:
161+ bulkInsert. saveAll(connection, persons. stream());
162+ });
150163 // And assert all have been written to the database:
151164 Assert . assertEquals(numEntities, getRowCount());
152165 }
0 commit comments