I want to get the value of the result in query.
This is my query / repository file:
@Query("select p.name, p.contact_no, p.email_address, p.time_submitted, p.date_due from Application p where p.application_number like ?1")
List<Application> getApplicationSummaryInfo(String application_number);
Service:
public List<Application> getApplicationSummaryInfo(String application_number);
ServiceImpl:
@Override
public List<Application> getApplicationSummaryInfo(String application_number) {
return (List<Application>)applicationRepository.getApplicationSummaryInfo(application_number);
}
Controller:
List<Application> app_info = applicationService.getApplicationSummaryInfo(application_no);
I only know how to access this in jsp file using foreach. But I want to access the fields in my controller file.
I tried doing this:
List<Application> app_info = applicationService.getApplicationSummaryInfo(application_no);
System.out.println(app_info.get(0));
and I get this result:
[Ljava.lang.Object;@28bf8e6e
then I tried getting the exact "name" field value
List<Application> app_info = applicationService.getApplicationSummaryInfo(application_no);
System.out.println(app_info.get(0).getName());
but I get this error
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class com.pckg_name.model.Application ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; com.rtc_insurance.model.Application is in unnamed module of loader 'app')
really hope you could help me. Thank you!