Drafts and copies
Copy stored inactive translations to a managed draft while setting its active fields yourself.
Draft
Persist the active language first
A draft is a new managed entity with a different ID. Set its ordinary fields for the Session locale before copying inactive translations.
Copy the remaining languages
Run in one localized Session and transaction. The return value counts copied locale rows, not fields.
scala
val source = session.find(classOf[Page], sourceId)
val draft = new Page
draft.id = java.util.UUID.randomUUID()
draft.title = source.title
session.persist(draft)
val copiedLocales: Int =
translations.copyInactive(session, source, draft)
Copy semantics
Copy stored rows
copyInactive copies raw stored values for every source locale except the active Session locale. It does not synthesize fallback values.
Target-row rules
Matching target locale rows are replaced field by field.
Target locales absent from the source remain in place.
Both entities must be managed by the installed factory and have different IDs.
The tenant filter and existing target-row optimistic versions still apply.
Loaded state stays loaded
The copy does not update either managed entity's already loaded fields. Use a new Session to observe any changed fallback.