Hi, I have a table in my database, it has a price, what I want to do is if the price changes I want the old price to be logged into another table. PRICE, PRICE_HISTORY
Now another elelment is that each entity with a price will have a timestamp for when that price was created. So that the timestamp will also be checked.
So the rules will be.
A Price comes in. check the price is it different to price in PRICE Table then check incoming price timestamp, if the pricestamp is greater than the timestamp in the PRICE table
insert into PRICE table, insert into PRICE_HISTORY
If price is it different to price in PRICE Table but the pricestamp is not greater than the timestamp in the PRICE table
then insert into PRICE_HISTORY only
One way to do this is my coding that logic into the java itself. Which would be easy.
What I would like to know, is, is there a way to do this on the database. So that when I insert data into the table PRICE, JPA will handle the logic that I detailed above.