@Retention(value=RUNTIME) @Target(value=FIELD) @Documented @Inherited @API(status=STABLE, since="6.0") public @interface Id
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.Copyright © 2019–2021 Neo4j, Neo4j Sweden AB. All rights reserved.