commit 2ac98c6d8c712e5de360d1dc64da4f4ecd93c0d1
parent 7c3f54744920d85977ce4b027068005e8594c5aa
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Sat, 11 Jan 2020 09:28:50 +0100
debug
Diffstat:
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/nexus/src/main/kotlin/DB.kt b/nexus/src/main/kotlin/DB.kt
@@ -38,8 +38,7 @@ fun dbCreateTables() {
Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver")
transaction {
- // addLogger(StdOutSqlLogger)
-
+ addLogger(StdOutSqlLogger)
SchemaUtils.create(
EbicsSubscribersTable
)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -345,7 +345,6 @@ class EbicsOrderSignatureEntity(id: EntityID<Int>) : IntEntity(id) {
var signatureValue by EbicsOrderSignaturesTable.signatureValue
}
-
object EbicsUploadTransactionChunksTable : IdTable<String>() {
override val id =
text("transactionID").entityId()
@@ -353,7 +352,6 @@ object EbicsUploadTransactionChunksTable : IdTable<String>() {
val chunkContent = blob("chunkContent")
}
-
class EbicsUploadTransactionChunkEntity(id : EntityID<String>): Entity<String>(id) {
companion object : EntityClass<String, EbicsUploadTransactionChunkEntity>(EbicsUploadTransactionChunksTable)
@@ -363,12 +361,12 @@ class EbicsUploadTransactionChunkEntity(id : EntityID<String>): Entity<String>(i
fun dbCreateTables() {
- Database.connect("jdbc:sqlite:libeufin-sandbox.sqlite3", "org.sqlite.JDBC")
- // Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver")
+ // Database.connect("jdbc:sqlite:libeufin-sandbox.sqlite3", "org.sqlite.JDBC")
+ Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver")
TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
transaction {
-
+ addLogger(StdOutSqlLogger)
SchemaUtils.create(
BankTransactionsTable,
BankCustomersTable,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -38,6 +38,8 @@ import io.ktor.routing.post
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
+import org.jetbrains.exposed.sql.StdOutSqlLogger
+import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.transactions.transaction
import org.joda.time.DateTime
@@ -53,7 +55,6 @@ import java.text.DateFormat
import javax.sql.rowset.serial.SerialBlob
import javax.xml.bind.JAXBContext
-
class CustomerNotFound(id: String?) : Exception("Customer ${id} not found")
class BadInputData(inputData: String?) : Exception("Customer provided invalid input data: ${inputData}")
class BadAmount(badValue: Any?) : Exception("Value '${badValue}' is not a valid amount")
@@ -61,6 +62,7 @@ class UnacceptableFractional(statusCode: HttpStatusCode, badNumber: BigDecimal)
"Unacceptable fractional part ${badNumber}"
)
+val LOGGER: Logger = LoggerFactory.getLogger("tech.libeufin.sandbox")
fun findCustomer(id: String?): BankCustomerEntity {
@@ -72,6 +74,7 @@ fun findCustomer(id: String?): BankCustomerEntity {
}
return transaction {
+ addLogger(StdOutSqlLogger)
BankCustomerEntity.findById(idN) ?: throw CustomerNotFound(id)
}
}
@@ -139,6 +142,7 @@ fun sampleData() {
}
val customerEntity = BankCustomerEntity.new {
+ addLogger(StdOutSqlLogger)
name = "Mina"
}
@@ -200,8 +204,6 @@ fun calculateBalance(id: Int, start: String?, end: String?): BigDecimal {
return ret
}
-val LOGGER: Logger = LoggerFactory.getLogger("tech.libeufin.sandbox")
-
fun main() {
dbCreateTables()