2

I am facing weird issue I have kotlin class like below

class RequestCenterDetails : Serializable{
var instituteId: String? = null
var centerId: String? = null
var centerKey: String? = null
var instituteKey: String? = null
var studentId: String? = null
var studentUID: String? = null
var studentFullName: String? = null
var studentEmailId: String? = null
var status: String? = null
var requestTime: Long? = null
var grantTime: Long? = null
var grantUserUID: String? = null
var grantUserEmailID: String? = null
var rejectComment: String? = null
var grantUserName: String? = null
var active: Boolean? = null

var instituteName: String? = null
var centerAddress: String? = null
var centerLocation: GeoPoint? = null

 // this function return value is getting stored in firebase
 fun isActiveRequest() : Boolean {
   return  active ?: false
}
}

and this is how i am saving into firebase

DatabaseReference requestRef = studentAccessRequestRef.child("/" + appfirebaseUserId + "/" + requestDetails.getCenterKey());
    requestRef.setValue(requestDetails);

and this is how its store its return type

enter image description here

I want to know why it is storing function return value. #AskFirebase

FaisalAhmed
  • 3,469
  • 7
  • 46
  • 76
  • According to [this answer](https://stackoverflow.com/a/37514605/1524450) the Firebase Database SDK will serialize properties for which there is a JavaBean-style getter. `isActiveRequest` probably qualifies as such a getter, hence why its value is serialized. – Michael Sep 04 '17 at 15:10

1 Answers1

4

Just use @Exclude annotation to avoid that, otherwise Firebase SDK triggers that value to POJO object due to variable serialization.

Try something like following:

@Exclude
fun isActiveRequest(): Boolean = active ?: false
AlexTa
  • 5,133
  • 3
  • 29
  • 46