@PrimaryKey (jdo)

The @javax.jdo.annotation.PrimaryKey annotation is used by JDO/DataNucleus to indicate that a property is used as the primary key for an entity with application-managed identity.

Apache Causeway also uses this annotation in a very minimal way: to ensure that the framework’s own logic to initialize newly instantiated objects (eg using FactoryService#create(…​) does not touch the primary key, and also to ensure that the primary key property is always disabled (read-only).

Apache Causeway parses the @NotPersistent annotation from the Java source code; it does not query the JDO metamodel. This means that it the @NotPersistent annotation must be used rather than the equivalent <field> XML metadata.

Moreover, while JDO/DataNucleus will recognize annotations on either the field or the getter method, Apache Causeway (currently) only inspects the getter method. Therefore ensure that the annotation is placed there.