I have the same question here. I'm using NeoDatis under DataNucleus and not finding a way to ensure two User objects with the same field aren't added to the DB
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How can I define a Field to be Unique? Is it possible to define a Field as being Unique for Primary Key purposes.
Hi,
you can do like this:
ODB odb = open("baseName");
ClassRepresentation clazz = odb.getClassRepresentation(IndexedObject.class);
String indexFields = { "name", "duration" };
clazz.addUniqueIndexOn("index1", indexFields, true);
Olivier
I have the same question here. I'm using NeoDatis under DataNucleus and not finding a way to ensure two User objects with the same field aren't added to the DB