2

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!

Viet
  • 17,944
  • 33
  • 103
  • 135

1 Answers1

2

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?

Fabio
  • 66
  • 3
  • Hi Fabio! Thanks for addressing this old problem. I changed direction and adopted SQLite. I may come back for db4o. It'd be great if you'd share your piece of code. I'll accept it as the best answer. Thanks. – Viet May 26 '10 at 11:45