Setting unique key constraint for Db4oEmbedded EmbeddedConfiguration
I want to set unique key constraint for Db4oEmbedded EmbeddedConfiguration.
Here goes my code:
EmbeddedConfiguration myConf = Db4oEmbedded.newConfiguration();
myConf.common().objectClass(NotyUser.class).objectField("username").indexed(true);
myConf.common().add(new com.db4o.constraints.UniqueFieldValueConstraint(NotyUser.class, "username"));
The last line throws exception. I don't know why. I'm running Android SDK 1.5 and db4o 7.12 for Java. Please kindly开发者_如何学运维 advise. Thanks!
I ran the code snippet you posted with a simple NotyUser class (just a String username field) and no exception was thrown neither in db4o-7.12 in android 1.5, nor db4o trunk with android 2.1.
What exception was thrown there? and can you post the NotyUser class?
精彩评论