openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miroslav Nachev <m...@space-comm.com>
Subject Re: How to mark records for deleting without real deleting using Callback Methods
Date Wed, 19 Dec 2007 07:43:28 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
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.<br>
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:<br>
1. Boolean<br>
2. Some kind of enumeration<br>
3. Others<br>
<br>
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:<br>
&nbsp;&nbsp;&nbsp; PERSIST - this will force the logic to continue to work as
now.<br>
&nbsp;&nbsp;&nbsp; DO_NOTHING - the next persist/update/delete operation will
not be
invoked. The question here is how to proceed with Post operations?<br>
&nbsp;&nbsp;&nbsp; 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.<br>
<br>
Can you give me your comments, ideas and directions?<br>
<br>
What to be the name of the enumeration class and its Enum members?<br>
<br>
<br>
Regards,<br>
Miro.<br>
<br>
Patrick Linskey wrote:
<blockquote
 cite="mid:7262f25e0711051313g19c26dd0uf2aec099d4654ae0@mail.gmail.com"
 type="cite">
  <pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:miro@space-comm.com">&lt;miro@space-comm.com&gt;</a>
wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">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.

    </pre>
  </blockquote>
  <pre wrap=""><!---->


  </pre>
</blockquote>
<br>
</body>
</html>

Mime
View raw message