UPDATE query to set a new field after schema change


I've added a new property/field to one of my objects and want to set the value of this (boolean) property to false for all existing entities in the DB.

I tried to execute an update statement with the Explorer tool.

The statement ends and tells me that 1000 entities have been updated. I then save the changes to the DB via file->save. But when I execute a select on the DB I see that the field is still "null" for all instances.

How do I initialize the field?


You are right. Currently UPDATE queries can only update existing fields, and old objects that do not have the fields are not updated. This should be fixed in future versions.

The workaround is to write some code (even in a simple console application) that update the objects in a loop within an active transaction, without using an UPDATE query.

ObjectDB Support

A new issue was added to the issue tracking system based on this post.

Further discussions and updates regarding this problem will be in the issue tracking.

ObjectDB Support