private PaymentLog createPaymentLog(BigDecimal usdAmount, Date blockTime, Investor investor) { String txId = "txId0"; java.util.Date creationDate = new java.util.Date(); CurrencyType currency = CurrencyType.ETH; // Value doesn't matter, only the amount in usd matters. BigInteger weiAmount = BigInteger.ONE; BigInteger tomicsAmount = null; PaymentLog paymentLog = null; boolean succeeded = false; int i = 1; while (!succeeded) { try { paymentLog = paymentLogService.saveTransactionless( new PaymentLog(txId, creationDate, currency, blockTime, weiAmount, USD_FX_RATE, usdAmount, investor, tomicsAmount, TransactionStatus.BUILDING)); succeeded = true; } catch (DataIntegrityViolationException ignore) { } txId = "txId" + i++; } return paymentLog; }