Unfortunately I still get the same result when using either method. Here
the new test code:
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.*;
public class OrientDBTest {
public final static String url = "memory:test";//"plocal:c:/tmp/orientdb"
public static void main(String[] args) {
OrientGraphFactory factory = new OrientGraphFactory(url, "admin", "admin");
// ... create database ...
OrientGraphNoTx graphNoTx = factory.getNoTx();
OrientVertexType person = graphNoTx.createVertexType("Person");
person.createProperty("name", OType.STRING);
person.createProperty("age", OType.INTEGER);
// final Parameter<?, ?> UNIQUE_INDEX = new Parameter<String,
String>("type", "UNIQUE_HASH_INDEX");
// graphNoTx.createKeyIndex("name", Vertex.class, new Parameter<String,
String>("class", "Person"), UNIQUE_INDEX);
// person.createIndex("person.nameIdx", OClass.INDEX_TYPE.UNIQUE, "name");
OCommandSQL cmd = new OCommandSQL();
cmd.setText("create index Person.name on Person (name) unique" );
graphNoTx.command(cmd).execute();
graphNoTx.shutdown();
// ... populate data ...
OrientGraph graph = factory.getTx();
long t = System.currentTimeMillis();
for (int i=0;i<10000;i++) {
OrientVertex v1 = graph.addVertex("class:Person");
Map<String,Object> props = new HashMap<String,Object>();
props.put("name", "Jill");
props.put("age", 33);
v1.setProperties(props);
if (i%1000==0)
graph.commit();
}
graph.commit();
System.out.println("Time: "+(System.currentTimeMillis()-t));
Iterator<Vertex> it = graph.getVerticesOfClass("Person").iterator();
System.out.println(it.next().getProperty("name") + " "
+it.next().getProperty("name"));
graph.shutdown();
}
}
Now it does not complain any more about doing schema changes in a
transaction but still no enforcement of the constraint:
May 14, 2015 9:36:26 AM com.orientechnologies.common.log.OLogManager log
INFO: OrientDB auto-config DISKCACHE=1,276MB (heap=494MB os=3,819MB
disk=32,320MB)
Time: 609
May 14, 2015 9:36:27 AM com.orientechnologies.common.log.OLogManager log
INFO: - closing storage: test...
Jill Jill
I am using 2.0.8. Should I revert to an older version to try this?
Timm
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.