Guest User

Untitled

a guest
Jun 12th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. package things
  2.  
  3. import org.springframework.boot.autoconfigure.SpringBootApplication
  4. import org.springframework.boot.runApplication
  5. import org.springframework.web.bind.annotation.RestController
  6. import org.springframework.web.bind.annotation.GetMapping
  7. import org.springframework.data.jpa.repository.JpaRepository
  8. import javax.persistence.Entity
  9. import javax.persistence.Id
  10. import javax.persistence.GeneratedValue
  11.  
  12. interface ThingRepository : JpaRepository<Thing, Long> {
  13. }
  14.  
  15. @RestController
  16. class ThingController(private val repository: ThingRepository) {
  17. @GetMapping("/test_trigger")
  18. fun trigger() {
  19. val things: MutableList<Thing> = mutableListOf()
  20. for (i in 3000..3013) {
  21. things.add(Thing(i))
  22. }
  23. repository.saveAll(things)
  24. }
  25. }
  26.  
  27. @Entity
  28. data class Thing (
  29. var value: Int,
  30. @Id
  31. @GeneratedValue
  32. var id: Long = -1
  33. )
  34.  
  35. @SpringBootApplication
  36. class Application {
  37. }
  38.  
  39. fun main(args: Array<String>) {
  40. runApplication<Application>(*args)
  41. }
  42.  
  43. jdbc.driverClassName = org.h2.Driver
  44. jdbc.url = jdbc:h2:mem:db
  45. jdbc.username = sa
  46. jdbc.password = sa
  47.  
  48. hibernate.dialect=org.hibernate.dialect.H2Dialect
  49. hibernate.hbm2ddl.auto=create
  50.  
  51. spring.jpa.generate-ddl = true
  52. spring.jpa.show-sql = true
  53.  
  54. spring.jpa.properties.hibernate.jdbc.batch_size = 10
  55. spring.jpa.properties.hibernate.order_inserts = true
  56. spring.jpa.properties.hibernate.order_updates = true
  57. spring.jpa.properties.hibernate.jdbc.batch_versioned_data = true
  58.  
  59. import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  60.  
  61. plugins {
  62. val kotlinVersion = "1.2.30"
  63. id("org.springframework.boot") version "2.0.2.RELEASE"
  64. id("org.jetbrains.kotlin.jvm") version kotlinVersion
  65. id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
  66. id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
  67. id("io.spring.dependency-management") version "1.0.5.RELEASE"
  68. }
  69.  
  70. version = "1.0.0-SNAPSHOT"
  71.  
  72. tasks.withType<KotlinCompile> {
  73. kotlinOptions {
  74. jvmTarget = "1.8"
  75. freeCompilerArgs = listOf("-Xjsr305=strict")
  76. }
  77. }
  78.  
  79. repositories {
  80. mavenCentral()
  81. }
  82.  
  83. dependencies {
  84. compile("org.springframework.boot:spring-boot-starter-web")
  85. compile("org.springframework.boot:spring-boot-starter-data-jpa")
  86. compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
  87. compile("org.jetbrains.kotlin:kotlin-reflect")
  88. compile("org.hibernate:hibernate-core")
  89. compile("com.h2database:h2")
  90. }
  91.  
  92. ./gradlew bootRun
  93.  
  94. curl http://localhost:8080/test_trigger
  95.  
  96. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  97. Hibernate: call next value for hibernate_sequence
  98. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  99. Hibernate: call next value for hibernate_sequence
  100. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  101. Hibernate: call next value for hibernate_sequence
  102. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  103. Hibernate: call next value for hibernate_sequence
  104. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  105. Hibernate: call next value for hibernate_sequence
  106. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  107. Hibernate: call next value for hibernate_sequence
  108. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  109. Hibernate: call next value for hibernate_sequence
  110. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  111. Hibernate: call next value for hibernate_sequence
  112. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  113. Hibernate: call next value for hibernate_sequence
  114. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  115. Hibernate: call next value for hibernate_sequence
  116. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  117. Hibernate: call next value for hibernate_sequence
  118. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  119. Hibernate: call next value for hibernate_sequence
  120. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  121. Hibernate: call next value for hibernate_sequence
  122. Hibernate: select thing0_.id as id1_0_0_, thing0_.value as value2_0_0_ from thing thing0_ where thing0_.id=?
  123. Hibernate: call next value for hibernate_sequence
  124. Hibernate: insert into thing (value, id) values (?, ?)
  125. Hibernate: insert into thing (value, id) values (?, ?)
  126. Hibernate: insert into thing (value, id) values (?, ?)
  127. Hibernate: insert into thing (value, id) values (?, ?)
  128. Hibernate: insert into thing (value, id) values (?, ?)
  129. Hibernate: insert into thing (value, id) values (?, ?)
  130. Hibernate: insert into thing (value, id) values (?, ?)
  131. Hibernate: insert into thing (value, id) values (?, ?)
  132. Hibernate: insert into thing (value, id) values (?, ?)
  133. Hibernate: insert into thing (value, id) values (?, ?)
  134. Hibernate: insert into thing (value, id) values (?, ?)
  135. Hibernate: insert into thing (value, id) values (?, ?)
  136. Hibernate: insert into thing (value, id) values (?, ?)
  137. Hibernate: insert into thing (value, id) values (?, ?)
  138.  
  139. start transaction
  140. INSERT INTO table VALUES (1, 2)
  141. end transaction
  142. start transaction
  143. INSERT INTO table VALUES (3, 4)
  144. end transaction
  145. start transaction
  146. INSERT INTO table VALUES (5, 6)
  147. end transaction
  148.  
  149. start transaction
  150. INSERT INTO table VALUES (1, 2)
  151. INSERT INTO table VALUES (3, 4)
  152. INSERT INTO table VALUES (5, 6)
  153. end transaction
  154.  
  155. start transaction
  156. INSERT INTO table VALUES (1, 2), (3, 4), (5, 6)
  157. end transaction
  158.  
  159. spring.jpa.properties.hibernate.jdbc.batch_size = 50
  160. spring.jpa.properties.hibernate.order_inserts = true
  161. ....
Add Comment
Please, Sign In to add comment