revert(account): restore original two-persist pattern for OfficialBotAccount token
Build & Test (NowChessSystems) TeamCity build finished

Reverts the Hibernate-related changes introduced during PR review:
- Remove nullable = false from OfficialBotAccount.token (caused PropertyValueException
  at first persist() since token is assigned after id is generated)
- Restore double persist() pattern: first persist() gets generated UUID, then token
  is generated using that id and entity is persisted again with dirty tracking

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LQ63
2026-06-09 14:44:20 +02:00
parent 4d54122d24
commit 2d9ceca097
2 changed files with 5 additions and 3 deletions
@@ -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)
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)
}