#47: BankAccountBalanceDO.kt

plugins/org.projectforge.plugins.banking/src/main/kotlin/org/projectforge/plugins/banking/BankAccountBalanceDO.kt

Path: ./plugins/.../BankAccountBalanceDO.kt · Type: Kotlin entity (JPA + Hibernate Search) · Lines: 79 · Source: GitHub

79 lines · 46 code · 25 comments · 8 blank

What it does

The JPA entity for bank account balances — a record of an account's balance at a specific date. Extends DefaultBaseDO (ProjectForge's base entity class providing id, created, lastUpdate, deleted). Uses 4 layers of annotation: JPA (persistence), Hibernate Search (full-text indexing), Jackson (JSON serialization), and ProjectForge custom annotations (@PropertyInfo for UI metadata).

Annotation layers per field

FieldTypeJPAHibernate SearchJacksonUI
bankAccount BankAccountDO? @ManyToOne(LAZY), @JoinColumn @IndexedEmbedded(depth=1), SHALLOW reindex @JsonSerialize(IdOnlySerializer) @PropertyInfo(i18nKey="plugins.banking.account")
amount BigDecimal? @Column(scale=2, precision=12) @PropertyInfo(type=CURRENCY)
date LocalDate? @Column(name="date_col") @GenericField @PropertyInfo
comment String? @Column(length=LENGTH_TEXT) @FullTextField @PropertyInfo(i18nKey="comment")

Naming conventions

ElementValueConvention
TableT_PLUGIN_BANKING_ACCOUNT_BALANCET_ prefix for all ProjectForge tables, PLUGIN_ for plugin entities
FK columnbanking_account_fk_fk suffix for foreign key columns
Date columndate_colExplicit naming to avoid reserved-word conflicts with date
Named query IDBankAccountBalanceDO_FindByBankAccount{ClassName}_{Purpose} pattern

Hibernate Search integration

@Indexed + @FullTextField on comment enables full-text search across all balance records. @IndexedEmbedded(includeDepth = 1) on bankAccount indexes the bank account's fields one level deep — searching for "IBAN" in the full-text index would find the parent BankAccountDO. ReindexOnUpdate.SHALLOW means changing a BankAccountDO reindexes its balance records automatically.

Key takeaways