Insert records into embedded field of OrientDB class from select

时间秒杀一切 提交于 2019-12-06 08:54:22

问题


I am evaluating OrientDB database.

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).

Now I would like to insert data from class OrderItem into class Order based on OrderID.

I have tried SQL like

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 ...

I do understand that embedded record should not have RecordId so I have tried

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 ...

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) ...

Ales


回答1:


I have found the solution

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


来源:https://stackoverflow.com/questions/33186867/insert-records-into-embedded-field-of-orientdb-class-from-select

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!