ObjectDB ObjectDB

World database - Changing country ID


Hi, I am getting familiar with OpenDB as I am considering using it in some project.

I opened Sample world DB in ObjectDB Explorer - and couldn't find my country, as it has invalid id ( ez instead of cz ). I changed the id of country to "cz". But when I try to find the country: SELECT c FROM Country c WHERE id = "cz" no results are returned. If i find it by name, I can see ID has changed to cz. However Country#ez is still displayed in the top.

When I save the changes and close and open it ObjectDB again id is back on ez. Changing county name works OK.

So the question is - is it possible to change field which is primary key? If so what am I doing wrong?



Changing the primary key of an existing entity object is not allowed and the Explorer should be fixed to prevent it.

If you have to change the primary key you should create a new entity object with the new primary key and delete the old entity object (and of course, update relevant references).

Regarding the primary key in the world example database - the data is derived from the CIA Factbook, in which the internal code of the Czech Republic is "ez" and not "cz":

<option value="hr"> Croatia </option>
<option value="cu"> Cuba </option>
<option value="cc"> Curacao </option>
<option value="cy"> Cyprus </option>
<option value="ez"> Czech Republic </option>
<option value="da"> Denmark </option>

This is indeed different than the conventional 2 letter country codes.

ObjectDB Support

Thanks for clarification.



To post on this website please sign in.