Mapping Data to Models: an overview
Storing query results in model objects lets your program reuse the data without querying the database again.
Journeyman · Java · SQL · Updated
In the previous examples we connected to our database and used the data immediately. Once we completed our loop our access to that data was gone, but what if we wanted to display the products again? We would have to execute another query on the database.
A better approach would be to store the values we received from the database in a variable. Then, we would be able to use that data as many times as we need to without needing to connect to the database repeatedly.