When using OrientDB Object API in schemaless mode, is it possible to have a field in a POJO marked as unique?
/**
The entity
*/
public class FooEntity {
@Column(unique=true)
private String bar;
public String getBar() {
return this.bar;
}
public void setBar(String bar) {
this.bar = bar;
}
}
And this is how the entity is registered, somewhere in another location in the code:
oObjectDatabase.getEntityManager().registerEntityClasses(FooEntity.class.getName());
OrientDB mechanism to map entities does not take into account the JPA annotations, but how could the same effect be achieved?
Would it be the best solution to add the constraint programmatically to the schema after registering the entity?
To add some constraint like unique (that is done through an unique index) you need to define the property in the schema, this means that you cannot have a unique constraint and be schema-less.
And yes for the OrientDB object 2.2.x and before the best way to define unique property is doing some programmatically or scripting schema definition after you registered the entity.
Bye