Rename Application StringIdentity

#1

I don't think JDO supports altering an entity's Application Identity.  Does ObjectDB?

@PersistenceCapable public class MyClass implements Serializable, Cloneable{
    @Id private StringIdentity id;
    ...
}

 

PersistenceManager persistenceManager = ...;
Transaction transaction = persistenceManager.currentTransaction();
try{
    transaction.begin();
    MyClass myPersistedClass = persistenceManager.getObjectById(MyClass.class, new StringIdentity("UniqueExisting"));
    myPersistedClass.id = new StringIdentity("UniqueNew");
    transaction.commit();
}finally{
    if(transaction.isActive()) transaction.rollback();
}

Would the above code keep my persisted object in the ObjectDB datastore and just change its "id" attribute?  (And update indexes and references appropriately?)  Or, does ObjectDB reject the attempt with an Exception?

 

#2

ObjectDB doesn't support changing the primary key (id) of objects, since that may affect references from other objects and indexes.

ObjectDB Support

Reply