Found two getters or fields with conflicting case sensitivity for property

前端 未结 6 1506
陌清茗
陌清茗 2020-12-20 17:08

Can anyone check if there are errors in it because I always get an error

com.google.firebase.database.DatabaseException: Found two getters or fields

相关标签:
6条回答
  • 2020-12-20 17:15

    I just got the same problem but i solved it first check that you have same variable name as firebase jason table variable. In your case CV is returned as Cv in your java class so correct it first than your check the firebase jason table name of that variable CV .

    0 讨论(0)
  • 2020-12-20 17:16

    You can map the name without changing variable name using @PropertyName annotation

    Kotlin Eg:

    data class Category(
        @PropertyName("Image")
        var img:String="",
        @PropertyName("Names")
        var name:String="")
    
    0 讨论(0)
  • 2020-12-20 17:34
    1. Brother your all variables in class SignupTeacher is private.
    2. Just make sure the variables you are using in this class should as it is as you are using in firebase. Look in my case

    1. And put the variables in your class in order the order you used in firebase Thanks
    0 讨论(0)
  • 2020-12-20 17:35

    Simply make sure that all the variables in your model class are declared as private

    ie

    private String name;
    

    instead of

    String name;
    
    0 讨论(0)
  • 2020-12-20 17:41

    Try to fix the capitalization on your fields and methods. firstName, getFirstName... etc

    Your error is on the CV field, where the method should be setCV to match the case of the field, though, you should name it cv following Java naming contentions. And the method is then get or setCv

    public String getCv() {
        return cv;
    }
    
    public void setCv(String cv) {
        this.cv = cv;
     }
    

    I would also suggest not storing passwords as part of your objects. Especially if they are plain text. You send passwords to the database to check for validity or to update; it's seldom a good idea to read them out and persist them elsewhere

    0 讨论(0)
  • 2020-12-20 17:41

    The Firebase JSON serialization name is controlled by the annotation PropertyName, if the name starts with a capital letter. You have two options

    1) Complain to complain
    2) use @PropertyName("Complain")

    public class Order implements Serializable {
    
    private String Complain;
    
    public Order() {
     Complain = "";
    }
    
    @PropertyName("Complain")
    public String getComplain() {
        return Complain;
    }
    
    @PropertyName("Complain")
    public void setComplain(String complain) {
        Complain = complain;
    }
    

    }

    reference https://stackoverflow.com/a/45809982/9315431

    0 讨论(0)
提交回复
热议问题