Storing LinkedSet in OrientDB class throws Impossible to serialize invalid link #-1:-1

171 Views Asked by At

I am trying to insert a record in a vertex in OrientDB using python client. the code is as follows

       print(recommendationCluster['recommendation'])
        for recommendation in recommendationCluster['recommendation']:
            item = menuitems.loadMenuItemWithId(str(recommendation),orientclient)
            items.append(item._rid)
        print("Creating cluster of ", items)            
        cluster['recommendeditems'] = items
        dbData = {}
        dbData['@RecommendationCluster']=cluster
        print("Storing recommendation cluster ", dbData)        
        newCluster = orientclient.record_create(-1, dbData)

In the console i see the message

Storing recommendation cluster  {'@RecommendationCluster': {'recommendeditems': ['#126:2', '#124:8']}}

Which suggests it has got the links to the right items and is performing the insert.

But the record_create fails and i get the following exception in the OrientDB server console

com.orientechnologies.orient.core.exception.ODatabaseException: Impossible to serialize invalid link #-1:-1

Would appreciate if someone can point out what i am doing wrong here.

1

There are 1 best solutions below

0
On

Fixed the issue. As the recommenditem is a LinkSet, the values to be passed to the array should be reference to the Link object

for recommendation in recommendationCluster['recommendation']:
            item = menuitems.loadMenuItemWithId(str(recommendation),orientclient)
            items.append(item._rid)

has to change to

for recommendation in recommendationCluster['recommendation']:
            item = menuitems.loadMenuItemWithId(str(recommendation),orientclient)
            items.append(pyorient.OrientRecordLink(item._rid))

That change fixed the issue and the records are getting inserted successfully