cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How can I create constraints using Java API?

How do I create the following constraints with the Java APIs?
CREATE CONSTRAINT ON (entity:Entity) ASSERT(entity.prefix, entity.name) IS NODE KEY;
CREATE CONSTRAINT ON (entity:Entity) ASSERT exists(entity.name);

I am looking at ConstraintCreator API documentation and cannot figure it out

1 REPLY 1

Just run Cypher using the Java API - there shouldn't be a need to use ConstraintCreator at all.

https://neo4j.com/docs/java-reference/current/tutorials-java-embedded/cypher-java/