Calculation of values ​​after hibernation of data retrieval from DB

We use hibernation for the school and we sell loans. We have a loan class that is constant and depending on the information about the loan (amount of payments, total amount, etc.) the application should calculate all payment quotes for a specific loan.

So, we have a Quote class with information regarding this quote, and Loan class has a list of all its quotes (composition between classes).

Since the quote information is computable, I think it shouldn't be in the DB.

My question is specifically how do I get Hibernate to calculate and populate the list of quotes when it returns a loan from the DB.

Clarification: the loan class has a method to calculate and populate its quotation list, I can't figure out how to start it when hibernate retrieves it from the DB.

Update. Since we have a data layer (where the Loan class is) and a business layer (where you actually work with the data and in turn call the DAO layer), I added a method call to the business layer right before returning the object from DB. Is this best practice? Final update

Thank,

+3


source to share


1 answer


  • Just because some data is calculated, it doesn't mean that it shouldn't be stored in the database. In fact, redundancy is often used to improve system performance. In addition, denormalized data is very useful for reports, statistics, and business intelligence tools.
  • Thinking that calculating Quote in the business layer might be a good choice, but it depends on the context of your application. Is this quote data used only to change system state, or is it also used in reports? Are you expecting a lot of data in the database? Do you need a stat of all quotes for all loans? Is this targeting your application? Did he get an external reporting engine? If any of these questions have a yes, you should consider storing the calculated data in a database


0


source







All Articles