Annotation Interface Id


@Retention(RUNTIME) public @interface Id
Use this annotation to specify the Id property for each pojo class. To work properly with PojoRepository.write, each pojo class must have one and only one property annotated with the Id annotation. The property annotated with Id is used to generate a unique URI in MarkLogic Server for each persisted instance, and thus should be a property with a unique value for each instance.

This annotation can be associated with a public field:
    import com.marklogic.client.pojo.annotation.Id;
    public class MyClass {
      @Id
      public Long myId;
    }
or with a public getter method:
    public class MyClass {
      private Long myId;
      @Id
      public Long getMyId() {
        return myId;
      }
      // ... setter methods ...
    }
or with a public setter method:
    public class MyClass {
      private Long myId;

      // ... getter methods ...

      @Id
      public void setMyId(Long myId) {
        this.myId = myId;
      }
    }
This annotation is used only at runtime to generate unique uris, so there is no need to run GenerateIndexConfig to do anything with this annotation.