Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 2.24 KB

File metadata and controls

41 lines (25 loc) · 2.24 KB
  1. summary How To Upgrade Objectify v4 To v5

Upgrading

Objectify v5 brings two major changes:

 * The native storage format for embedded objects has changed from dot-separated property names to the new {{{EmbeddedEntity}}} native structure.
 * The code that translates back and forth between POJOs and native data structures has been rewritten from scratch.

This allows Objectify to offer great new features like polymorphism and lifecycle methods in embedded objects. However, it may require to migrate the structure of existing data.

Incredibly Important Migration Instructions

  • IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT!*
If you have used or to store data with previous versions of Objectify, and you do not follow these instructions, *you will lose data*. Furthermore, once you have followed these instructions, *you cannot rollback to a previous version of Objectify* or your data will be lost. If you have not used or , the migration is unnecessary.

  # Upgrade to v4.1.x
  # Set {{{ObjectifyFactory.setSaveWithNewEmbedFormat(true)}}}
  # For every entity that has an {{{@Embed}}} structure, {{{load()}}} + {{{save()}}} the entity (ideally in a transaction).

This will convert embedded structures into the format that Objectify 5 understands.

V5 Changes

Converting from 4.1 to 5 involves minimal changes:

  * {{{@EntitySubclass}}} has been renamed to {{{@Subclass}}}.
  * Remove any reference to the {{{@Embed}}} annotation. It does not exist in Objectify 5; any class which is not natively stored will be treated as an embedded class automatically.
  * Similarly, {{{@EmbedMap}}} has been removed. Fields of type {{{Map<String, ?>}}} are assumed to be embedded maps.
  * The {{{@Owner}}} annotation has been renamed to {{{@Container}}}.

Many limitations of Objectify4 no longer apply to Objectify5:

  * Nesting of collections of embedded objects is unrestricted.
  * Embedded objects can be polymorphic.
  * Embedded objects can have lifecycle methods.

The API for custom translators has changed. If you use custom translators, check the javadocs.

As always, seek help at the Objectify Google Group if you have any questions.