字段在无模式模式下的OrientDB对象API中唯一
在无模式模式下使用OrientDB对象API时,POJO中的字段是否可以标记为唯一字段在无模式模式下的OrientDB对象API中唯一,orientdb,orientdb2.2,nosql,Orientdb,Orientdb2.2,Nosql,在无模式模式下使用OrientDB对象API时,POJO中的字段是否可以标记为唯一 /** The entity */ public class FooEntity { @Column(unique=true) private String bar; public String getBar() { return this.bar; } public void setBar(String bar) { this.bar
/**
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;
}
}
这就是实体注册的方式,在代码中的另一个位置:
oObjectDatabase.getEntityManager().registerEntityClasses(FooEntity.class.getName());
映射实体并不考虑JPA注释,但如何实现相同的效果
注册实体后,以编程方式将约束添加到架构中是否是最好的解决方案?要通过唯一索引添加一些类似unique的约束,您需要在架构中定义属性,这意味着您不能有唯一约束,也不能缺少架构 对于OrientDB对象2.2.x和之前,定义unique属性的最佳方法是在注册实体后以编程方式或脚本方式进行模式定义 再见