Home » Support » Forum » World database - Changing country ID

World database - Changing country ID

#1

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?

Thanks

#2

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

Thanks for clarification.


Post Reply

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