【发布时间】:2019-05-10 17:14:28
【问题描述】:
我想从 firebase 中提取数据我有两个 digit 类型的字段,这会导致兼容性问题
除数字以外的其他字符数据都有效
package fr.halas.loginhalas.Filter;
import com.google.firebase.firestore.IgnoreExtraProperties;
@IgnoreExtraProperties
public class Affichage {
public static final String FIELD_CREATOR_NAME = "CreatorName";
public static final String FIELD_USERID = "UserID";
public static final String FIELD_MODULE = "Module";
public static final String FIELD_SECTION = "Section";
public static final String FIELD_GROUPE = "Groupe";
private String CreatorName;
private String Module;
private String UserID;
private long Section;
private long Groupe;
public Affichage(String CreatorName,String UserID,String Module, long Section, long Groupe) {
this.CreatorName = CreatorName;
this.UserID = UserID;
this.Module = Module;
this.Section = Section;
this.Groupe = Groupe;
}
public Affichage() {
// empty default constructor, necessary for Firebase to be able to deserialize users
}
public String getCreatorName() {
return CreatorName;
}
public void setCreatorName(String creatorName) {
CreatorName = creatorName;
}
public String getModule() {
return Module;
}
public void setModule(String module) {
Module = module;
}
public String getUserID() {
return UserID;
}
public void setUserID(String userID) {
UserID = userID;
}
public long getSection() {
return Section;
}
public void setSection(long section) {
Section = section;
}
public long getGroupe() {
return Groupe;
}
public void setGroupe(long groupe) {
Groupe = groupe;
}
}
@SuppressLint("SetTextI18n")
public void bind(final DocumentSnapshot snapshot, final OnAffichageSelectedListener listener) {
final Affichage affichage = snapshot.toObject(Affichage.class); // Error is here !
creator.setText(affichage.getCreatorName());
moduleView.setText(affichage.getModule());
groupeView.setText("Groupe: " + affichage.getGroupe());
sectionView.setText("Section: " + affichage.getSection());
错误信息是 05-10 18:00:36.850 19488-19488/fr.halas.loginhalas E/AndroidRuntime: 致命异常: main 进程:fr.halas.loginhalas,PID:19488 java.lang.RuntimeException:无法反序列化对象。无法将 java.lang.String 类型的值转换为 long(在字段 'Groupe' 中找到)
【问题讨论】:
-
@AKSW (Groupe & Section) 的类型是数字
标签: java android firebase google-cloud-firestore