Can't modify @EmbeddedId in ObjectDB Explorer

#1

Hi!

There is entity Journal with @EmbeddedId JournalId. Id's content can't be seen/modified from ObjectDB Explorer from its class. Ok, I get this. It's an @EmbeddedId, so it should depend only on its parent.

Problem: id's content can't be modified through its parent neither.

Scenario: open db in ObjectDB Explorer, open entity Journal, expand the id, try to modify date/id, save, then refresh data / reopen db, and you'll see that it wasn't modified.

Any solutions? ObjectDB v. 2.5.1

#2

ObjectDB doesn't support modifying object IDs, not just in the Explorer, but by the application as well. You set a primary key before persisting an entity, and it cannot be modified later.

Therefore replacing a primary key requires creating a new entity object with the new primary key, copying the content of the old entity object to the new object, updating references to the new object, and finally deleting the old object.

ObjectDB Support
#3

Thanks for your fast answer.

Is there any reason why ObjectDB/ObjectDB E shouldn't allow this functionality? It might be very handy, rather than writing special logic when you need just a small modification. It's a habit from RDBMS, where everything can be modified.

#4

Object Ids are usually immutable in object oriented databases. Because object Ids are used in references between objects, the ability to modify them could cause broken references. It is also a good practice to keep primary keys fixed (in RDBMS too).

Accordingly, currently this feature has a low priority.

ObjectDB Support

Reply