Hello,
I need to do versioning of data, where the current record is stored in
one database table and the old records are stored in another table.
I'm using EJB entity beans.
What's the best way to do this moving of the old data into the history
table and putting the new data into the current table?
Something like a trigger at the EJB level when the object is
re-persisted is probably what I'm looking for, but if the container
caches the data then there's no guarantee as to when this would
happen.
Does anyone have any thoughts on this, please?
Thanks,
David.
Marek Lange - 31 Jul 2003 20:55 GMT
David Smith schrieb:
> Hello,
>
[quoted text clipped - 11 lines]
>
> Does anyone have any thoughts on this, please?
This is hard to do due to the caching of the EJB Container. You should
try to switch off the caching completely to achieve constant validity of
the entity bean data. You could try to trigger the operations in the
ejbStore() method when the container synchronizes the data to the db.
-marek
dspublic-REMOVE THIS AND HYPENS- - 02 Aug 2003 07:56 GMT
Te common pratice for this is to allow it to happen at the DB level.
Have your dba's set up a trigger to write the record to a history or
audit table
Don Stacy
>David Smith schrieb:
>> Hello,
[quoted text clipped - 19 lines]
>
>-marek
Klas - 06 Aug 2003 15:48 GMT
This is, I think, is not a recommended solution. Switching of the cache does
more harm than good.
/Klas
> David Smith schrieb:
> > Hello,
[quoted text clipped - 19 lines]
>
> -marek
Marek Lange - 07 Aug 2003 09:34 GMT
> This is, I think, is not a recommended solution. Switching of the cache does
> more harm than good.
Agreed. Cache is king. As someone has written in another post before,
EJB is not the recommended solution for the problem.
-marek
Klas - 06 Aug 2003 13:19 GMT
First, it might be a better solution to keep all the records in the same
table with a version number?
Otherwise...I suppose you have som type of facade in form of a stateless
session bean which performs the create, remove, update, delete of the
entity? If not then you should definately thinking about refactoring and
build one. If you have one then it's easy (I'll use a person as example):
a) find the 'Person' entity that is going to be archived.
b) create a new 'ArchivedPerson' entity and fill it with the values from the
'Person' entity and additional data.
c) create a new 'Person' entity and fill it with the new values.
d) you are done.
/Klas
> Hello,
>
[quoted text clipped - 14 lines]
> Thanks,
> David.