I'm trying to return the record that I got from my database. But I'm having a problem on how I can do that because the data than I retrieved from the database is in a different class from the return parameter.
public List<Record> getRecord(List<Request> requests) { List<Record> records = new ArrayList<>(); for (Request request : requests) { Billing billing = billingRepository .findByBillingCycleAndStartDateAndEndDate( request.getBillingCycle() , request.getStartDate() , request.getEndDate()); if (billing != null) { // Need to add "billing" to "records" list here } } return records; } Record.class
public class Record { private int billingCycle; private LocalDate startDate; private LocalDate endDate; private String accountName; private String firstName; private String lastname; private double amount; public Record() { } //Getters and setters Billing.class
public class Billing { private int billingId; private int billingCycle; private String billingMonth; private Double amount; private LocalDate startDate; private LocalDate endDate; private String lastEdited; private Account accountId; public Billing() { } //Getters and setters What can I do? and please explain the answer so I can understand it. I really want to learn