Using JDO / DataNucleus / NeoDatis datastore
I added @Unique to a field of a persistable object, however I am allowed to create multiple objects which violate the unique constraint. The docs for DataNucleus/NeoDatis suggest that Unique fields are supported.
@PersistenceCapable
public class User {
@Persistent
@Unique
private String username;
//...
}
If I add multiple objects to the DB with the same username there's no problem doing so.
It appears that the DataNucleus implementation for NeoDatis doesn't support unique attributes. In NeoDatis it requires that you add a unique index on the field (see link below for NeoDatis forums describing this).
http://sourceforge.net/projects/neodatis-odb/forums/forum/619814/topic/3409305