I am facing this problem.
I have a method who do many things and persist a lot of data. This method is also read only, using a parameter i set the flush method to manual to never persist changes. When the method first runs it create the data, and it is all ok. But after i run this method again as a read only, to achieve the same effect as the first one i need to delete all files it created before, for example, this method creates the week payment for many persons based on the week payments made in the month, if a person has to pay 1000 in the month, and the month has 4 four week, we have:
month amount less payments made divided with left weeks of the month week 1 = (1000 - 0) / 4 = 250 week 2 = (1000-250) / 3 = 250 week 3 = (1000-500) / 2 = 250 week 4 = (1000-750) / 1 = 250
if i run the method on the week 3, it creates the payment ok. The way i get the paid amount is fetching all payments and do a sum of each payment for every person. When i run again the week 3, i set the flush method to manual, i delete all payments of this week and using the same algorithm to get the paid amonth, but the problem is that hibernate returns the 3 payment entities for each person (even i have delete one).
My question is, can i achieve the funtionality that i want or i forgot the idea?
This is just one example of what the method does, it also modified other entities, create other ones, etc. Basically the method delete and update every entity to get back to the original status, but even this hibernate returns the data as in the data base.
thank you for your time.
|