Class UntypedPermazenObject
- All Implemented Interfaces:
PermazenObject
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 Summary
-
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.permazen.PermazenObject
cascade, copyIn, copyOut, copyTo, delete, exists, getModelClass, getObjId, getPermazenClass, getPermazenTransaction, getSchemaId, isDetached, migrateSchema, recreate, resetCachedFieldValues, revalidate
-
Constructor Details
-
UntypedPermazenObject
public UntypedPermazenObject()
-