@Unique has no effect in DataNucleus w / NeoDatis

Using the JDO / DataNucleus / NeoDatis Data Warehouse

I added @Unique to the stable object field, however I am allowed to create several objects that violate the unique constraint. Docs for DataNucleus / NeoDatis show that unique fields are supported.

@PersistenceCapable
public class User {
 @Persistent
 @Unique
 private String username;
 //...
}

If I add several objects to the database with the same username, this is not a problem.

+3
source share
2 answers

It appears that the DataNucleus implementation for NeoDatis does not support unique attributes. NeoDatis requires a unique index to be added to the field (see the link below for NeoDatis forums describing this).

http://sourceforge.net/projects/neodatis-odb/forums/forum/619814/topic/3409305

+1

?

@Unique(name="USERNAME_IDX")
private String username;
+1

Source: https://habr.com/ru/post/1773768/


All Articles