Skip to content
Anjunar/ DOCS

Schema integration

Prepare generated translation tables and integrate stable IDs with Hibernate DDL Manager 1.2.0.

Identity

Give generated columns stable IDs

Hibernate DDL Manager 1.2.0 can manage the classless translation rows. Add stable @SchemaId values to the concrete localized entity and each translated member.

Stable translation identities

The runtime ID provider derives internal table and key IDs from the parent. A translated value column keeps its member ID.

scala
import com.anjunar.hibernateddl.hibernate.annotation.SchemaId @Entity @Table(name = "page") @SchemaId("7f3a9c21") @Localized(defaultLocale = "en") class Page: @Id @SchemaId("0a1b2c3d") var id: UUID = uninitialized @Translation @SchemaId("f34e45b6") var title: String = uninitialized
Migration

Choose the schema owner

When the DDL manager owns the schema, disable Hibernate generation and migrate after metadata build, before SessionFactory creation. The runtime artifact brings schema-integration 1.2.0 transitively.

Migrate the complete metadata

Set hibernate.hbm2ddl.auto to none on the runtime registry. Use the full application metadata and a configured migration DataSource.

scala
import com.anjunar.hibernateddl.integration.HibernateSchemaMigration val metadata = new MetadataSources(registry) .addAnnotatedClass(classOf[Page]) .buildMetadata() HibernateSchemaMigration.migrate(metadata, migrationDataSource) val factory = metadata.buildSessionFactory()
Existing databases

Adoption requires the complete schema to match the target exactly. Older generated varchar columns need the explicit text upgrade first. Legacy translation rows are separate and are not copied automatically.