[英]ClassCastException while using BackendlessCollection
java.lang.ClassCastException: java.util.HashMap cannot be cast to com.foodonomic.foodonomic.Category java.lang.ClassCastException:无法将java.util.HashMap强制转换为com.foodonomic.foodonomic.Category
I was working with Backendless.com APIs in one of my app. 我在其中一个应用程序中使用Backendless.com API。 There when I Tried to call data from server 当我尝试从服务器调用数据时
using this method 使用这种方法
//Category is my class whose object I was trying to fetch from the Backendless //Server
Backendless.Data.mapTableToClass( "CategoryCode", CategoryCode.class );
Backendless.Persistence.of(CategoryCode.class).find(new AsyncCallback<BackendlessCollection<CategoryCode>>() {
@Override
public void handleResponse(BackendlessCollection<CategoryCode> foundContacts) {
Log.d("vivz","Inside handle response");
List<CategoryCode> code=foundContacts.getData();
Log.d("vivz",code.get(1).toString());
}
@Override
public void handleFault(BackendlessFault fault) {
//Snackbar.make(coordinatorLayout,"Network error, check your internet connection",Snackbar.LENGTH_LONG).show();
Log.d("vivz", "Error");
}
});
I got a Runtime Exception java.lang.ClassCastException: java.util.HashMap cannot be cast to com.foodonomic.foodonomic.Category 我收到了运行时异常java.lang.ClassCastException:java.util.HashMap无法转换为com.foodonomic.foodonomic.Category
I have asked the same question there on Backendless Support, keeping in mind to get answers from more users of Backendless I am posting this here. 我在Backendless支持那里问过同样的问题,请记住要从更多Backendless用户那里得到答案,我在此发布。 Here is the link to the post that I had posted there on Backendless 这是我在Backendless上发布的帖子的链接
http://support.backendless.com/topic/java-lang-classcastexception-java-util-hashmap-cannot-be-cast-to-com-foodonomic-foodonomic-category#comment-13573 http://support.backendless.com/topic/java-lang-classcastexception-java-util-hashmap-cannot-be-cast-to-com-foodonomic-foodonomic-category#comment-13573
当我在Backendless支持论坛上回复时,解决方案是将CategoryCode类的默认构造函数声明为public。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.