mirror of
https://github.com/corda/corda.git
synced 2025-06-05 00:50:52 +00:00
Fix SQL statement used by CashSelection on Oracle database. (#781)
This commit is contained in:
parent
01a07481ad
commit
a256ad972e
@ -49,10 +49,18 @@ class CashSelectionOracleImpl : AbstractCashSelection(maxRetries = 16, retrySlee
|
|||||||
"""+
|
"""+
|
||||||
(if (notary != null)
|
(if (notary != null)
|
||||||
" AND vs.notary_name = ?" else "") +
|
" AND vs.notary_name = ?" else "") +
|
||||||
(if (onlyFromIssuerParties.isNotEmpty())
|
(if (onlyFromIssuerParties.isNotEmpty()) {
|
||||||
" AND ccs.issuer_key_hash IN (?)" else "") +
|
val repeats = generateSequence { "?" }
|
||||||
(if (withIssuerRefs.isNotEmpty())
|
.take(onlyFromIssuerParties.size)
|
||||||
" AND ccs.issuer_ref IN (?)" else "") +
|
.joinToString (",")
|
||||||
|
" AND ccs.issuer_key_hash IN ($repeats)"
|
||||||
|
} else { "" }) +
|
||||||
|
(if (withIssuerRefs.isNotEmpty()) {
|
||||||
|
val repeats = generateSequence { "?" }
|
||||||
|
.take(withIssuerRefs.size)
|
||||||
|
.joinToString (",")
|
||||||
|
" AND ccs.issuer_ref IN ($repeats)"
|
||||||
|
} else { "" }) +
|
||||||
""")
|
""")
|
||||||
SELECT transaction_id, output_index, pennies, total, lock_id
|
SELECT transaction_id, output_index, pennies, total, lock_id
|
||||||
FROM entry where total <= ? + pennies"""
|
FROM entry where total <= ? + pennies"""
|
||||||
@ -64,10 +72,12 @@ class CashSelectionOracleImpl : AbstractCashSelection(maxRetries = 16, retrySlee
|
|||||||
statement.setString(++pIndex, lockId.toString())
|
statement.setString(++pIndex, lockId.toString())
|
||||||
if (notary != null)
|
if (notary != null)
|
||||||
statement.setString(++pIndex, notary.name.toString())
|
statement.setString(++pIndex, notary.name.toString())
|
||||||
if (onlyFromIssuerParties.isNotEmpty())
|
onlyFromIssuerParties.map { it.owningKey.toStringShort() }.forEach {
|
||||||
statement.setObject(++pIndex, onlyFromIssuerParties.map { it.owningKey.toStringShort() as Any }.toTypedArray())
|
statement.setObject(++pIndex, it)
|
||||||
if (withIssuerRefs.isNotEmpty())
|
}
|
||||||
statement.setObject(++pIndex, withIssuerRefs.map { it.bytes.toHexString() as Any }.toTypedArray())
|
withIssuerRefs.map { it.bytes }.forEach {
|
||||||
|
statement.setBytes(++pIndex, it)
|
||||||
|
}
|
||||||
statement.setLong(++pIndex, amount.quantity)
|
statement.setLong(++pIndex, amount.quantity)
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/2683214/get-query-from-java-sql-preparedstatement
|
// https://stackoverflow.com/questions/2683214/get-query-from-java-sql-preparedstatement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user