2
votes

I have two different classes: Record and Location. Record has a location property that links to Location class.

I want to create a record with a new location in one statement pretty much like this:

insert into record content {location:{name:"EDR"}}

I was hoping this would create new location with name EDR and link it to location property of record but it throws this exception.

com.orientechnologies.orient.core.exception.OValidationException: The field 'record.location' has been declared as LINK but the value is not a record or a record-id

Can anyone help me please?

3

3 Answers

1
votes

You can use

insert into record set location = (insert into location(name) values ("EDR"))
1
votes

you could also try this:

insert into Record set location = (insert into Location content {name:'EDR'})

Hope it helps

1
votes

Seems the inner object is taken as MAP instead of document. However try to force the fact the inner object is a document and not a MAP (In OrientDB you can have both):

insert into record content {"@type":"d", "location":{"@type":"d", "name":"EDR"}}