lundi 2 mai 2022

How to fetch and update data present in a field by knowing the fields name as a string?

I have a CustomerDetailsEntity with fields ticketNum, firstName, lastName, dob, address, etc. For a certain Ticket number, I received a String data specifying some field names for which data might be incorrect.

For example, for ticketNum = 123, I received a field checkFields = "firstName, address"; So I have to fetch data of firstName and address for ticketNum 123 from DB and be able to update it.

I tried to solve this using java reflection concept.

CustomerDetailsEntity customer = customerDetailsRepo.findByTicketNum(123);

Field[] fields = customer.getfields;

I am getting error saying getfields() is not a method. How do I solve this issue? Any corrections or suggestions are greatly appreciated.





Aucun commentaire:

Enregistrer un commentaire