Annotation Interface Id


@Retention(RUNTIME) @Target({FIELD,ANNOTATION_TYPE}) @Documented @Inherited @API(status=STABLE, since="6.0") public @interface Id
This annotation is included here for completeness. It marks an attribute as the primary id of a node entity. It can be used as an alternative to Id and it may provide additional features in the future.

To use assigned ids, annotate an arbitrary attribute of your domain class with Id or this annotation:

 @Node
 public class MyEntity {
        @Id String theId;
 }
 
You can combine @Id with @Property with assigned ids to rename the node property in which the assigned id is stored.

To use internally generated ids, annotate an arbitrary attribute of type java.lang.long or java.lang.Long with @Id and @GeneratedValue.

 @Node
 public class MyEntity {
        @Id @GeneratedValue Long id;
 }
 
It does not need to be named id, but most people chose this as the attribute in the class. As the attribute does not correspond to a node property, it cannot be renamed via @Property.

To use externally generated ids, annotate an arbitrary attribute with a type that your generated returns with @Id and @GeneratedValue and specify the generator class.

 @Node
 public class MyEntity {
        @Id @GeneratedValue(UUIDStringGenerator.class) String theId;
 }
 
Externally generated ids are indistinguishable to assigned ids from the database perspective and thus can be arbitrarily named via @Property.
Since:
6.0
Author:
Michael J. Simons