Setting unique key constraint for Db4oEmbedded EmbeddedConfiguration

Posted by Viet on Stack Overflow See other posts from Stack Overflow or by Viet
Published on 2010-04-10T04:53:55Z Indexed on 2010/04/10 5:03 UTC
Read the original article Hit count: 489

Hi, 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!

© Stack Overflow or respective owner

Related posts about db4o

Related posts about java