i wrote a code to get value of a attribute of a object using reflection but it gives nosuchfield exception.The class which contain id field is
public class PartialSettBank {
// empty constructor
public PartialSettBank() {
}
protected Integer id;
protected String bankCode;
protected String bankName;
protected String description;
protected Integer isDeleted = 0;
protected Integer isPosted = 1;
protected Integer active;
protected LocalDateTime created;
protected String createdBy;
protected LocalDateTime updated;
protected String updatedBy;
------getter setter()
}
I want to access id field using reflection
Field id = object.getClass().getDeclaredField("id");
id.setAccessible(true);
this object is from class 'PartialSettBank'.object contains id field.I checked it.why it is giving such error i have no idea.
Aucun commentaire:
Enregistrer un commentaire