Reputation: 118
We're using hibernate for school, and we're implementing loans. We have a Loan class which is persistent, and depending on the information on the loan (amount of payments, total due etc.) the app should calculate the entire payment quotes for the specific loan.
So we have a Quote class with the information regarding that quote and the Loan class has a list of all its quotes (composition between the classes).
Since the quote information is calculable, I think it shouldn't be on the DB.
My question specifically is , how do I get Hibernate to calculate and populate the list of quotes when it brings up a Loan from the DB.
Clarification: Loan class has a method for calculating and populating it's list of quotes, I can't figure out the way to make it run 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 on the data, and in turn calls the DAO Layer), I have added a call to the method in the business layer right before I return the object from the DB. Is this best practice? End update
Thanks,
Upvotes: 3
Views: 73
Reputation: 17367
Upvotes: 1