开发者

@Unique doesn't have any effect in DataNucleus w/ NeoDatis

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 user开发者_如何学JAVAname there's no problem doing so.


Did you specify a name for your unique constraint ?

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜