Skip to content
Anjunar/ DOCS

Session lifecycle

Handle refresh, optimistic conflicts, tenant isolation and deletion within the supported runtime.

State

Reload deliberately

refresh reloads the locale-resolved fields and their row version. A refresh with unflushed translation-row changes is rejected; clear and evict discard the corresponding snapshots.

Refresh clean state

Load and refresh in a transaction. Perform this before creating unsaved editor changes in the same Session.

scala
val page = session.find(classOf[Page], pageId) session.refresh(page)
Optimistic conflicts

Concurrent writes to the same locale row reject the stale commit, including editor versus domain writes. Different locale rows can be edited independently.

Tenant

Fix tenant and locale together

A shared-table parent with a String @TenantId uses the tenant-aware Session overload. Loading, HQL and editor access stay within that Session tenant.

A tenant-bound Session

The generated translation row carries the tenant and a cascading reference to the parent's ID and tenant key.

scala
val session = HibernateI18n.openSession(factory, "de", "tenant-a") try // Begin a transaction, load and edit the tenant's entities. () finally session.close()
Bulk deletion

Database cascades delete translation rows, but HQL bulk deletion leaves already managed objects stale. Clear the Session after a bulk operation before loading affected entities again.