Documentation Index
Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide covers the essential changes needed to migrate your Ditto Java app from v4 to v5. The main architectural shift is moving from identity-based initialization to a three-phase configuration model with CompletableFuture-based APIs. Also required: v5 uses DQL (Ditto Query Language) for all data operations. See the DQL Migration Guide for query migration steps.AI Agent Prompt
Use this prompt when working with an AI coding assistant to migrate your Ditto Java app from v4 to v5.Copy AI Migration Prompt (Click to Expand)
Copy AI Migration Prompt (Click to Expand)
Ditto Instance Initialization
v5 separates initialization into three distinct phases for better clarity and control:- Clear separation of connection, initialization, and authentication concerns
- CompletableFuture-based async authentication
- No workarounds needed (transport config, DQL strict mode, v3 sync disable)
- Type-safe configuration with compile-time validation
Replace Initialization
Replace Key changes:
new Ditto() constructor with DittoFactory.create(config).- Use
DittoConfig.Builderpattern instead ofDittoIdentity appIdβdatabaseId.OnlinePlaygroundβnew DittoConfig.Connect.Server(...).OfflinePlaygroundβnew DittoConfig.Connect.SmallPeersOnly(null)- Remove
updateTransportConfig,disableSyncWithV3(), and DQL strict mode queries
Update Authentication
Set authentication handler separately after initialization.Key changes:
- Authentication now uses
setExpirationHandlercallback - Handler called when auth required (
timeUntilExpiration == 0) or token expiring - Use
DittoAuthenticationProvider.development()for playground tokens - Custom auth:
new DittoAuthenticationProvider("your-provider")
Additional Changes
DQL Strict Mode Behavior Change
Choose the appropriate migration path based on your current v4 configuration:Currently Using DQL with DQL_STRICT_MODE=true (v4 default)
Currently Using DQL with DQL_STRICT_MODE=true (v4 default)
If youβre currently using the v4 default (
DQL_STRICT_MODE=true), you must explicitly set strict mode to true in v5 before starting sync or executing any queries.To migrate to
DQL_STRICT_MODE=false (the new v5 default), contact Ditto Customer Support for guidance.Currently Using DQL with DQL_STRICT_MODE=false
Currently Using DQL with DQL_STRICT_MODE=false
If you explicitly set
DQL_STRICT_MODE=false in v4, no changes are required.v5 uses DQL_STRICT_MODE=false as the default, so your existing DQL queries will behave identically. You can upgrade freely.Optional: You can remove the explicit ALTER SYSTEM SET DQL_STRICT_MODE = false statement in v5 since this is now the default behavior.Currently Using Legacy Query Builder
Currently Using Legacy Query Builder
The Legacy Query Builder has been removed in v5. All queries must be converted to DQL before upgrading.Good news: Legacy Query Builder functionality has 1:1 support with
DQL_STRICT_MODE=false (the v5 default), making migrations straightforward.Migration Steps:-
In v4: Set
DQL_STRICT_MODE=falseafter initialization: - Convert all queries from Legacy Query Builder to DQL See the Java LegacyβDQL Migration Guide for detailed conversion examples.
-
Upgrade to v5
No DQL configuration changes requiredβv5 defaults to
DQL_STRICT_MODE=false.
Default Persistence Directory
v5 includes the database ID in the default directory name:ditto-{databaseId} instead of ditto
To maintain v4 compatibility:
API Changes
ditto.startSync()βditto.getSync().start()ditto.stopSync()βditto.getSync().stop()ditto.isSyncActive()βditto.getSync().isActive()getPeerKeyString()βgetPeerKey()isConnectedToDittoCloud()βisConnectedToDittoServer()new Ditto()βDittoFactory.create(config)
Migration Checklist
Initialization
- Replace
new Ditto()withDittoFactory.create(config) - Create
DittoConfigwithdatabaseIdandconnectmode - Update
.OnlinePlaygroundβnew DittoConfig.Connect.Server(...) - Update
.OfflinePlaygroundβnew DittoConfig.Connect.SmallPeersOnly(null) - Remove
updateTransportConfigcalls - Remove
disableSyncWithV3()calls - Set
DQL_STRICT_MODE=trueBEFORE starting sync if maintaining v4 behavior
Authentication
- Set
setExpirationHandlercallback after initialization - Use
DittoAuthenticationProvider.development()for playground tokens - Remove authentication from identity configuration
Sync API
- Update
ditto.startSync()βditto.getSync().start() - Update
ditto.stopSync()βditto.getSync().stop() - Remove
disableSyncWithV3()calls
Breaking Changes
- Set
persistenceDirectoryif maintaining v4 directory structure - Update
getPeerKeyString()βgetPeerKey() - Update
isConnectedToDittoCloud()βisConnectedToDittoServer()
Verification
- Build compiles with zero errors
- No deprecated API warnings
- Observers update data immediately
- Authentication works before sync starts
- No memory leaks