Hi all,
I would like to have unique constraints operate on more than 1 field for several entities. How can I achieve this with db4o?
Thanks,
Walter
Hi all,
I would like to have unique constraints operate on more than 1 field for several entities. How can I achieve this with db4o?
Thanks,
Walter
Sounds like a composite key. Can you create a new class that contains the key-constituting fields, and use a member variable with that type in place of the key-constituting fields in your original class?
i.e. where you had
class Foo {
String given_name;
String family_name;
}
instead use
class Name {
String given_name;
String family_name;
}
class Foo {
Name name;
}
and make Foo.name
the unique field?
Hi
Currently db4o doesn't support the UniqueConstrain on multiple fields. You can set unique-constrains only field by field, but not combine them.
@Ladlestein Well the intention is good, but it doesn't work. db4o manageds objects by it referencial identity. When you apply the unique-constrain on the Foo.name, you ensure that the reference is unique. So no other object can have the same reference to a name object. But you're not interested that the reference is unique, but you want to have a unique content of the names.