Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
字段在无模式模式下的OrientDB对象API中唯一_Orientdb_Orientdb2.2_Nosql - Fatal编程技术网

字段在无模式模式下的OrientDB对象API中唯一

字段在无模式模式下的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

在无模式模式下使用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 = bar;
    }
}
这就是实体注册的方式,在代码中的另一个位置:

oObjectDatabase.getEntityManager().registerEntityClasses(FooEntity.class.getName());
映射实体并不考虑JPA注释,但如何实现相同的效果


注册实体后,以编程方式将约束添加到架构中是否是最好的解决方案?

要通过唯一索引添加一些类似unique的约束,您需要在架构中定义属性,这意味着您不能有唯一约束,也不能缺少架构

对于OrientDB对象2.2.x和之前,定义unique属性的最佳方法是在注册实体后以编程方式或脚本方式进行模式定义

再见