Skip to content

Commit 215a4d4

Browse files
committed
Improve SQL
1 parent 34125b7 commit 215a4d4

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

frameworks/Kotlin/hexagon/store_sql/src/main/kotlin/BenchmarkSqlStore.kt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,22 @@ class BenchmarkSqlStore(
6363

6464
override fun replaceWorlds(worlds: List<World>) {
6565
dataSource.connection.use { con: Connection ->
66-
con.autoCommit = false
6766
val stmtSelect = con.prepareStatement(SELECT_WORLD)
68-
val stmtUpdate = con.prepareStatement(UPDATE_WORLD)
69-
7067
worlds.forEach {
71-
val worldId = it.id
72-
val newRandomNumber = it.randomNumber
73-
74-
stmtSelect.setInt(1, worldId)
68+
stmtSelect.setInt(1, it.id)
7569
val rs = stmtSelect.executeQuery()
7670
rs.next()
7771
rs.getInt(2) // Read 'randomNumber' to comply with Test type 5, point 6
72+
}
7873

79-
stmtUpdate.setInt(1, newRandomNumber)
80-
stmtUpdate.setInt(2, worldId)
81-
// stmtUpdate.executeUpdate()
82-
stmtUpdate.addBatch()
74+
val stmtUpdate = con.prepareStatement(UPDATE_WORLD)
75+
worlds.forEach {
76+
stmtUpdate.setInt(1, it.randomNumber)
77+
stmtUpdate.setInt(2, it.id)
78+
stmtUpdate.executeUpdate()
79+
// stmtUpdate.addBatch()
8380
}
84-
stmtUpdate.executeBatch()
85-
con.commit()
81+
// stmtUpdate.executeBatch()
8682
}
8783
}
8884

0 commit comments

Comments
 (0)