vendredi 27 février 2015

orientdb property constraints like MANDATORY not failing on improper java api insertions



I have an orientdb setup with a class called MessageLog with a property messageId that has a constraint MANADATORY and NOT NULL. If i try to insert a record from the console with a null messageId it raises an exception telling that the property cannot be null. But when i do a simple insertion from the Java API the record is inserted with the property value null. How is that possible.


The java code is:



import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertexType;

public class OrientDbTrials {

public static void main(String[] args) {

OrientGraph graph = new OrientGraph("remote:localhost/blah","root","*****");
System.out.println("Connected to the db.");

Vertex messageLog = graph.addVertex("class:MessageLog");

System.out.println("Created new vertex : " + messageLog.toString());
messageLog.setProperty("messageId", null);
graph.commit();
System.out.println("Successfully saved it.");

}

}


Can somebody please explain this.




1 commentaire: