I am facing two very similar peoblems.
The First peoblem is that I have a composite key for which i am supplying the key values based on certain criteria.
Now, i have a screen from which i can get objects that are not yet persisted or also some objects that are persisted in the database and need to be updated.
Now i did try to veto with LifeCyle. And for a not yet persisted object if hibernate tries to update it, then i am doing a Veto, however it does not naturally then try to save that object.
So, in the documentation i read about Interceptor and the is "isUnsaved()" method. The challange i have with that is there is no class that i know of that implements a default interceptor, and that i can just override the "isUnsaved()" method.
What is the best way i can solve this, and if interceptoer is the way how can i use the interceptor with just implementing "isUnsaved()" method.
The other problem is similar a problem in a collection cascade.
I have a 4 level collection cascade, and in this scenario also, i have some objects that have to updated and some that have to be saved, at all levels.
Again i tried lifecyle and it faces the same problem as above.
What i mean by 4 level collection ascade is, A is one to many with B, B has one to many with C, C has one to many with D, and in any of these many's(B,C,D) there may be a new Object or a Persistant object needing to be updated.
I have set casacde-all in the mapping. So i am calling SaveOrUpdate(A), after i fill all the objects and i can clearly see that it is trying to Update rows that need to be inserted. As a side note i have KeyGen class for generating the ID's in this case for all levels of Objects(A,B,C,D).
I guess the way i will solve the first problem i wil also solve the next problem.
Thanks and Regards
Suchak Jani
|