What is the correct way to use audit feature?

In my test, it works well with normal Neo4jRepository save, but not work with neo4jTemplate save projection(modify time not update).

neo4jTemplate.save(MyNode.class).one(nodeProjection);

Also for repo save, I need fetch old node and set all new properties or the create time will be null like JPA, is this the only way for update?

The official doc is not mentioned too much information about this.
Auditing :: Spring Data Neo4j

Could you provide a little bit more insights to your MyNode and the node projection definition? There might be something missing in your case.
Please be reminded that e.g. the ids are needed to be present in the projection for this to work because they are being used to determine if the object is new or needs to get updated. So this has a direct effect on which fields gets updated by the versioning / auditing / optimistic locking mechanism.

It's just some simple pojo.

@Node
@Data
public class MyNode {
    @Id
    @GeneratedValue
    private UUID id;
    private String name;

    @CreatedDate
    private OffsetDateTime createTime;
    @LastModifiedDate
    private OffsetDateTime modifyTime;
}
@Data
public class MyNodeProjection {
    @Id
    private UUID id;
    private String name;
}

Have you tried to add the auditing related fields to the projection? Otherwise they will get skipped as properties.
Also I will run a few tests in the next days around this topic, because I am not sure if the auditing gets called for the projection classes at all. The auditing feature for setting the properties right is coming from Spring Data commons and there is no concept for persisting projections as we have in Spring Data Neo4j.

If I add in projection, I think I just use the entity :frowning:

In fact, I am very confused about audit feature in Spring Data Neo4j.
This is why I ask here instead open an issue in github.

Here is my use case:
I have some Nodes(with nested relation), and need audit feature.
All expose as CRUD api for user, and user can see the create time and modify time but can not modify them.

How to do this with Spring Data Neo4j?

I am following Spring Data JPA way now : fetch old entity, update all field with new value, call repository to save them. Then the audit field will get trigger for me.

Is Spring Data Neo4j need do the same? Or I can just update without fetch old entity and audit feature still work? In my test, the create time will be gone if I don't fetch old entity.

Yes, it would be the same but of course the entity itself. Spring Data JPA (as mentioned above as part of the other Spring Data modules) does not support projection-based saves.
The difference here is the projection. It works as a filter on the properties that will be persisted. And if the modify dates are not part of them, they won't get updated.