Home » Support » Forum » UPDATE query to set a new field after schema change

UPDATE query to set a new field after schema change

#1

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?

#2

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

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
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login