Hi,

I would like to register that as new feature and to start working on it. Before that I have to do some changes in the existing code and that is the reason to write this email. I wold like to co-ordinate that with you before to start working.
For this feature I have to changes something in callback logic for methods annotated with PrePersist, PreUpdate and PreRemove. The need of this changes are because the main logic need to be informed what to do after successful calling of the above methods. The other way of such signalization is if the method returns some value. If the return value is "void", then the logic will works as until now. Now the question is what value to return. There are many possible variants:
1. Boolean
2. Some kind of enumeration
3. Others

To answer on this question let's see what we need. We need to know should the next persistent (remove, update) operation be executed (insert, update or delete) or not? If Yes, this is easy because we back again to existing logic. If not we have to know what to do. To check the record state and if need to mark as removed/updated in JPA layer without physical database action or to continue with the existing logic. Because at the moment I see 3 states it is not possible to realize them just with Boolean return value. That's why I will need of some enumeration return type like that:
    PERSIST - this will force the logic to continue to work as now.
    DO_NOTHING - the next persist/update/delete operation will not be invoked. The question here is how to proceed with Post operations?
    CHECK_QUERY_CONDITION - the next persist/update/delete operation will not be invoked but JPA have to check query condition and if need to remove the record from the list of records because the select criteria is changed. For example when some record is removed but physically it is marked as removed and this condition is part of initial select condition.

Can you give me your comments, ideas and directions?

What to be the name of the enumeration class and its Enum members?


Regards,
Miro.

Patrick Linskey wrote:
Hi Miro,

There is no spec-supported way to do this. We have discussed adding
this sort of a feature directly to OpenJPA in the past, but have not
yet implemented it. You could do this "on your own" in a custom
ClassStrategy, but it's not particularly straightforward to do so
unfortunately.

Can you describe what your requirements are in a bit more detail, in
particular around relationship handling?

-Patrick

On Nov 5, 2007 11:56 AM, Miroslav Nachev <[EMAIL PROTECTED]> wrote:
  
Hi,

In one entity class I don't want to delete the records on delete operations.
Instead I would like to mark them as deleted using some flag. How can I do
that using some of the callback methods like PrePersist, ProPersist,
PreRemove or PostRemove?

The similar for Update. Instead to update the records I would like to
increase the number of versions for this record and to insert new record on
the place of the old. Which method to use PreUpdate or PostUpdate.

For both of the above how to stop the real delete/update operations?


Regards,
Miro.

    



  

Reply via email to