|
|
|
@ -20,7 +20,10 @@ import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
|
import javax.sql.DataSource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.MethodOrderer; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.Order; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.TestMethodOrder; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
@ -47,6 +50,7 @@ import org.springframework.jdbc.support.KeyHolder; |
|
|
|
* @author Jens Schauder |
|
|
|
* @author Jens Schauder |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@IntegrationTest |
|
|
|
@IntegrationTest |
|
|
|
|
|
|
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) |
|
|
|
public class JdbcRepositoryEmbeddedWithReferenceIntegrationTests { |
|
|
|
public class JdbcRepositoryEmbeddedWithReferenceIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired NamedParameterJdbcTemplate template; |
|
|
|
@Autowired NamedParameterJdbcTemplate template; |
|
|
|
@ -74,20 +78,26 @@ public class JdbcRepositoryEmbeddedWithReferenceIntegrationTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void batchInsertJdbcTemplate() { |
|
|
|
@Order(1) |
|
|
|
Map<String, ?> params = Map.of("id", 4711, "test", "text1"); |
|
|
|
void jdbcTemplateOne() { |
|
|
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|
|
|
System.out.println("insertJdbcTemplate"); |
|
|
|
SqlParameterSource[] sqlParameterSource = new SqlParameterSource[] { new MapSqlParameterSource(params) }; |
|
|
|
insert(); |
|
|
|
template.batchUpdate("INSERT INTO \"DUMMY_ENTITY2\" (\"ID\", \"TEST\") VALUES (:id, :test)", sqlParameterSource, |
|
|
|
|
|
|
|
keyHolder); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void batchInsertJdbcTemplate2() { |
|
|
|
@Order(2) |
|
|
|
|
|
|
|
void jdbcTemplateTwo() { |
|
|
|
|
|
|
|
System.out.println("rerunJdbcTemplate"); |
|
|
|
|
|
|
|
insert(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void insert() { |
|
|
|
Map<String, ?> params = Map.of("id", 4711, "test", "text1"); |
|
|
|
Map<String, ?> params = Map.of("id", 4711, "test", "text1"); |
|
|
|
|
|
|
|
MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(params); |
|
|
|
|
|
|
|
SqlParameterSource[] sqlParameterSources = new SqlParameterSource[] {sqlParameterSource}; |
|
|
|
|
|
|
|
|
|
|
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|
|
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|
|
|
SqlParameterSource[] sqlParameterSources = new SqlParameterSource[] { new MapSqlParameterSource(params) }; |
|
|
|
template.update("INSERT INTO \"DUMMY_ENTITY2\" (\"ID\", \"TEST\") VALUES (:id, :test)", sqlParameterSource, |
|
|
|
template.batchUpdate("INSERT INTO \"DUMMY_ENTITY2\" (\"ID\", \"TEST\") VALUES (:id, :test)", sqlParameterSources, |
|
|
|
|
|
|
|
keyHolder); |
|
|
|
keyHolder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|