Skip to content

feat: migrate from Hibernate JPA to Micronaut Data JDBC#3

Merged
Fyfar merged 5 commits into
masterfrom
jdbc-migration
Jun 14, 2026
Merged

feat: migrate from Hibernate JPA to Micronaut Data JDBC#3
Fyfar merged 5 commits into
masterfrom
jdbc-migration

Conversation

@Fyfar

@Fyfar Fyfar commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Replaces Hibernate/JPA with Micronaut Data JDBC to reduce JAR size (~85MB of Hibernate/ByteBuddy/JAXB removed) and startup time. Flattens the TABLE_PER_CLASS inheritance + @ElementCollection model into explicit junction tables (budget_account, security_user) with FK-column repos.

Also includes:

  • Docker: Alpine JRE base, BuildKit cache mounts, .dockerignore, v2.0.0
  • Micronaut AOT enabled for compile-time bean pre-computation
  • Schema managed via db/schema.sql (INIT=RUNSCRIPT); schema-generate: NONE
  • Telegram DefaultBotSession timeout noise suppressed in logback (expected)
  • @transactional on ConfigService.setConfig() to make delete+reinsert atomic
  • Null-safe userId guards in SecurityService and MessageService
  • Removed broken unused model→entity mapper direction from both mappers
  • ConfigInitializer uses count() instead of findAll() for existence checks
  • Diagnostic IllegalStateException messages when config rows are missing

Fyfar and others added 5 commits June 13, 2026 11:23
Replaces Hibernate/JPA with Micronaut Data JDBC to reduce JAR size (~85MB
of Hibernate/ByteBuddy/JAXB removed) and startup time. Flattens the
TABLE_PER_CLASS inheritance + @ElementCollection model into explicit
junction tables (budget_account, security_user) with FK-column repos.

Also includes:
- Docker: Alpine JRE base, BuildKit cache mounts, .dockerignore, v2.0.0
- Micronaut AOT enabled for compile-time bean pre-computation
- Schema managed via db/schema.sql (INIT=RUNSCRIPT); schema-generate: NONE
- Telegram DefaultBotSession timeout noise suppressed in logback (expected)
- @transactional on ConfigService.setConfig() to make delete+reinsert atomic
- Null-safe userId guards in SecurityService and MessageService
- Removed broken unused model→entity mapper direction from both mappers
- ConfigInitializer uses count() instead of findAll() for existence checks
- Diagnostic IllegalStateException messages when config rows are missing
- pom: exclude telegrambots' unused Jersey/Grizzly/HK2/Javassist webhook-server
  stack (long-polling only) — fat JAR 28MB -> 23MB, ~19MB dead weight gone
- BalanceHistoryRepository + UserRepository: CrudRepository with compile-time
  derived queries; drop hand-written @query + Pageable plumbing
- MonobankService: push day-initial-balance sort down into SQL (Optional finders)
- schema.sql is the single source of truth; tests now RUNSCRIPT the same schema
  (schema-generate: NONE) instead of generating lossy DDL from entities
- add ASC indexes for balance_history(account_id, time) and the config FKs
  (NOTE: ASC not DESC — a DESC index on TIMESTAMP WITH TIME ZONE hits an H2
  range-scan bug that returns wrong rows)
- ConfigInitializer: @transactional seeding; delete redundant TestBalanceHistoryRepository

All 23 tests green.
Any branch except master now builds (after tests pass) to
ghcr.io/fyfar/budgetbot:test, so a new version can be tested on the server by
swapping bot.image to :test and reverted by swapping back to :latest. Adds a
concurrency guard to cancel superseded builds on the same branch.
@Fyfar Fyfar merged commit f45c799 into master Jun 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant