使用文档API

时间:2015-11-26 07:01:49

标签: orientdb

https://github.com/orientechnologies/orientdb/issues/3612Insert records into embedded field of OrientDB class from select

相关

使用develop分支(2.2),

ODocument product = new ODocument("Product");
ODocument data = new ODocument("Price");
data.field("currency", "EUR");
product.field("data", data);
product.save();

使用事务数据库引发此类错误(而它与非tx一起使用):

The field 'Product.price' has been declared as EMBEDDED but the value is a document with the valid RecordID Price#220:-3

这是一个错误吗?

1 个答案:

答案 0 :(得分:2)

我尝试使用2.2快照,但它可以正常工作

ODatabaseDocumentTx db = new ODatabaseDocumentTx(path);
db.open("root","root");
db.command(new OCommandSQL("create class Product")).execute();
db.command(new OCommandSQL("create property Product.data EMBEDDED")).execute();
db.getMetadata().getSchema().reload();

ODocument product = new ODocument("Product");
ODocument data = new ODocument("Price");
data.field("currency", "EUR");
product.field("data", data);
product.save();