
com.marklogic.client.pojo.annotation.Id Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-client-api Show documentation
Show all versions of marklogic-client-api Show documentation
The official MarkLogic Java client API.
The newest version!
/*
* Copyright © 2024 MarkLogic Corporation. All Rights Reserved.
*/
package com.marklogic.client.pojo.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import com.marklogic.client.pojo.PojoRepository;
/** Use this annotation to specify the Id property for each pojo class.
* To work properly with {@link PojoRepository#write 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 {
* {@literal @}Id
* public Long myId;
* }
*
* or with a public getter method:
*
* public class MyClass {
* private Long myId;
* {@literal @}Id
* public Long getMyId() {
* return myId;
* }
* // ... setter methods ...
* }
*
* or with a public setter method:
*
* public class MyClass {
* private Long myId;
*
* // ... getter methods ...
*
* {@literal @}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
* {@link com.marklogic.client.pojo.util.GenerateIndexConfig} to do
* anything with this annotation.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Id {
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy