简体   繁体   English

将记录从select插入到OrientDB类的嵌入字段中

[英]Insert records into embedded field of OrientDB class from select

I am evaluating OrientDB database. 我正在评估OrientDB数据库。

I have two document classes imported from a relational database. 我有两个从关系数据库导入的文档类。

class Order with properties (ID: integer, OrderItems: EmbeddedList of OrderItem) 

and

class OrderItem with properties (ID: integer, OrderID: integer, PropA: string)

Both classes are filled with data from the database (except field Order.OrderItems). 这两个类都填充了数据库中的数据(Order.OrderItems字段除外)。

Now I would like to insert data from class OrderItem into class Order based on OrderID. 现在我想将OrderItem类中的数据插入到基于OrderID的类Order中。

I have tried SQL like 我试过像SQL一样

update Order set OrderItems = (select from OrderItem where OrderID = Order.ID)

without success, with error like 没有成功,有错误就好

The field 'Order.OrderItems' has been declared as EMBEDDEDLIST but the value is document with the valid RecordId ... 字段'Order.OrderItems'已声明为EMBEDDEDLIST,但值为具有有效RecordId的文档...

I do understand that embedded record should not have RecordId so I have tried 我明白嵌入式记录不应该有RecordId所以我试过了

update Order set OrderItems = (select PropA from OrderItem where OrderID = Order.ID)

without success, with error like 没有成功,有错误就好

The field 'Order.OrderItems' has been declared as EMBEDDEDLIST with linked class 'OrderItem' but the record has no class ... 字段'Order.OrderItems'已被声明为EMBEDDEDLIST,链接类'OrderItem',但记录没有类...

I have also tried 我也试过了

update Order
set OrderItems = (select @class, PropA from OrderItem where OrderID = Order.ID)

without success. 没有成功。

Is there any other way (OrientDB 2.1.4) ... 还有其他方法(OrientDB 2.1.4)......

Ales 强麦

I have found the solution 我找到了解决方案

update Order
set OrderItems = (select $current.exclude('@rid') from OrderItem where $parent.$current.ID = OrderID)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM