ERROR:Missing ___class property while saving HashMap - Java


I’m using Backendless to develop a JavaSE application.
It works really good, but when I try to save an Object with an attribute (“insumosNec”) of type HashMap<String, Float> I get this error:

ERROR:Missing ___class property for entity: insumosNec

In order to see if the problem was something else I created a TestObject with only that attribute and tried to save it with:


and the error is still there.
So, questions are:

    What does the error means? I've never heard about that __class prperty. Am I able to save an object with a HashMap as attribute? In that case, what is the problem?
Thanks! Marcos.

Hi Marcos,

When you have a Hashmap as a property of the object you save, Backendless saves that hashmap in a separate table. The ___class property designates what the name of that table should be. Try adding ___class to the hashmap in the insumosNec property and you will see the relation created on the server side.


Thanks for the reply… Sorry if it is a silly question, but what do you mean with “Try adding ___class to the hashmap in the insumosNec” and how can I do that in Java?

Thanks again!

Change your HashMap to HashMap<String, Object> and add the following to it:

HashMap<String, Object> insumosNec = new HashMap<String, Object>();
insumosNec.put( “___class”, “InsumosNec” );
… add your float values now
… add the hashmap as a property to your object
… save the object with the Backendless API

Hope this helps.



That solved the problem!



I have this problem with java objects also, how do I declare __class property? thank you