Skip to content
Anjunar/ DOCS

Entity mapping

Declare translated fields and converted values while keeping their ordinary domain types.

Mapping

Annotate the owning entity

@Localized declares the fallback policy; @Translation marks each property whose value belongs to a locale row. The parent has no column for that translated value.

A translated String

Use a UUID ID and consistent field access. A named translation column uses @Translation(column = ...).

scala
import com.anjunar.hibernatei18n.annotation.{Localized, Translation} @Entity @Table(name = "page") @SchemaId("7f3a9c21") @Localized(defaultLocale = "en", fallbackLocale = "en") class Page: @Id @SchemaId("0a1b2c3d") var id: UUID = uninitialized @Translation @SchemaId("f34e45b6") var title: String = uninitialized
scala
@Translation(column = "display_title") var title: String = uninitialized
Field or getter access

JavaBean getter access is supported too. Keep the ID and translated members on the same access path; mixed access and @Column directly on @Translation fail at bootstrap.

Conversion

Keep a typed value

A converted translated property must use a String database representation. The runtime derives encoding and decoding from the configured JPA converter.

A converted Markdown field

Add this member to Page with your Markdown type and JPA converter. No separate field registration or codec is needed.

scala
@Translation @SchemaId("cdef1234") @jakarta.persistence.Convert(converter = classOf[MarkdownConverter]) var content: Markdown = uninitialized