Cannot set null value to property by invoking ODocument.field({fieldName}, null), an ambiguous error

25 views
Skip to first unread message

Hung Tran

unread,
Jan 5, 2016, 1:00:14 PM1/5/16
to OrientDB
Hi,

I got an ambiguous error with this code

document.field(fieldName, null);// should it be "document.field(fieldName, (object)null)"

the error is 

The call is ambiguous between the following methods or properties: 'com.orientechnologies.orient.core.record.impl.ODocument.field(string, com.orientechnologies.orient.core.metadata.schema.OType)' and 'com.orientechnologies.orient.core.record.impl.ODocument.field(string, java.lang.Class)'

Any help will be very appreciated!

My Best,
Hung Tran


machak

unread,
Jan 5, 2016, 2:35:23 PM1/5/16
to OrientDB
Hi,
you need to cast null to either com.orientechnologies.orient.core.metadata.schema.OType or  java.lang.Class  
otherwise it is not possible to know which method you want to execute
so, call it like:
document.field(fieldName, (com.orientechnologies.orient.core.metadata.schema.OType)null) or with class cast..
hth,
/m
 

My Best,
Hung Tran


Hung Tran

unread,
Jan 5, 2016, 10:19:42 PM1/5/16
to OrientDB
Hi machak,

I think you misunderstood it. My case is trying to set a null value for a field name of document, your suggestion will not do that, that will return a field value instead.

By looking at the ODocument class, you will see there are 4 overloading methods of field()

1. Getters:
  • 1.1 field ( fieldName )
  • 1.2 field ( fieldName, conversionType )
  • 1.3 field ( fieldName, conversionType:OType )
2. Setters:
  • 2.1 field ( fieldName, fieldValue )
  • ....
My Best,
Hung Tran
Reply all
Reply to author
Forward
0 new messages