Package io.permazen

Class UntypedPermazenObject

java.lang.Object
io.permazen.UntypedPermazenObject
All Implemented Interfaces:
PermazenObject

public abstract class UntypedPermazenObject extends Object implements PermazenObject
Represents a PermazenObject whose type does not exist in the transaction's schema.

Instances of this class are used to represent objects with a type that is defined in some other database schema but not in the current one. This situation can occur when a new schema drops a previously defined Java model type when there are objects still existing in the database. If encountered, such objects are represented by instances of this class.

These objects are still fully accessible, but they must be accessed via introspection using the PermazenTransaction field access methods, with the migrateSchema parameter set to false (to prevent a TypeNotInSchemaException).

For example, suppose a schema update removes the Account class and replaces fields referencing Account objects with a copy of the accountId field. Then a corresponding schema migration might look like this:


      @OnSchemaChange
      private void applySchemaChanges(Map<String, Object> oldValues) {
          if (oldValues.containsKey("account")) {                                   // was replaced with "accountId"
              final PermazenObject acct = (PermazenObject)oldValues.get("account"); // has type UntypedPermazenObject
              final PermazenTransaction ptx = this.getTransaction();
              final String acctId = (String)ptx.readSimpleField(acct.getObjId(), "accountId", false);
              this.setAccountId(acctId);
          }
          // ...etc
      }
 
  • Constructor Details

    • UntypedPermazenObject

      public UntypedPermazenObject()