feat: NCS-82 add Swiss-system tournament module #55
@@ -76,6 +76,6 @@ class OfficialBotAccount extends PanacheEntityBase:
|
||||
|
||||
var createdAt: Instant = uninitialized
|
||||
|
||||
|
|
||||
@Column(nullable = false, length = 1024)
|
||||
@Column(length = 1024)
|
||||
var token: String = uninitialized
|
||||
// scalafix:on
|
||||
|
||||
@@ -205,7 +205,8 @@ class AccountService:
|
||||
bot.name = botName
|
||||
bot.createdAt = Instant.now()
|
||||
officialBotAccountRepository.persist(bot)
|
||||
bot.token = generateBotToken(bot.id, botName)
|
||||
bot.token = generateBotToken(bot.id, bot.name)
|
||||
|
lq64
commented
Same two-persist pattern. The root cause is that bot.id is not available before the first persist(). Either use a pre-assigned UUID (@Id with UUID.randomUUID() before persist) or derive the token from a field that doesn't require a DB round-trip. Two flushes per creation is a correctness risk under failure: if the second persist fails, the entity exists without a valid token. Same two-persist pattern. The root cause is that bot.id is not available before the first persist(). Either use a pre-assigned UUID (@Id with UUID.randomUUID() before persist) or derive the token from a field that doesn't require a DB round-trip. Two flushes per creation is a correctness risk under failure: if the second persist fails, the entity exists without a valid token.
|
||||
officialBotAccountRepository.persist(bot)
|
||||
Right(bot)
|
||||
|
||||
@Transactional
|
||||
@@ -216,7 +217,8 @@ class AccountService:
|
||||
bot.name = name
|
||||
bot.createdAt = Instant.now()
|
||||
officialBotAccountRepository.persist(bot)
|
||||
bot.token = generateBotToken(bot.id, name)
|
||||
bot.token = generateBotToken(bot.id, bot.name)
|
||||
officialBotAccountRepository.persist(bot)
|
||||
log.infof("Auto-registered official bot: %s", name)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user
Missing nullable = false. A just-constructed OfficialBotAccount starts with token = uninitialized, and AccountService does two separate persist() calls to work around this. Add nullable = false and generate the token before the first persist to collapse it to one round-trip and make the constraint explicit at the DB level.