Hi Pinaki Thank you for your quick reply. I'd implement the soft delete with two distinct functionalities.
The first would be to enhance the FilterDef. I'd add an inherit flag and a includeReference flag . E.g. @FilterDef(name = "isDeletedFilter", defaultCondition = "deleted = 0", inherit = "true", includeReference = "true"). This would allow me to define a filter on the base class (due to the inherit flag), which would be valid for all subclasses. The includeReference would indicate, thatloading a OneToMany inheritance, for the Many entities this filter is active. The second would be to add a BeforeDelete handler. This would be the same as the OnDelete but would return a boolean, if the entry should physically be deleted or not. The soft delete would be implemented by - Adding a FilterDef and defining a filter on the base class as described above with inherit = "true" and includeReference = "true". This would ensure, that any entities, marked as deleted would not be loaded. Either as Entity or as foreign key reference. - Creating a BeforeDelete handler, that "deletes" the Entity (by updating the Entry to be deleted and setting the deleted flag to true) and return false. This ensures the when a delete occurs, the entry is not physically deleted and it is marked as deleted. Please give me your view on this topic. Regards, Steven Pinaki Poddar wrote: > > Hi, >> is there any global Datafilter with OpenJPA available? > > This is an often requested feature, especially filter out 'softly > deleted' records. Also to filter multi-cardinality relations. But OpenJPA > does not (yet) have it. > Your requirements mention a more dynamic behavior. For example, in some > cases you want to access the softly deleted records, in some cases you > don't. Some filters are based on current user's security level. Few of the > inputs we will like to receive are > > a) what are the appropriate mechanics to describe the filter? > Class-level Annotations, Fetch Plan or a separate interface, query hints, > ....? > b) at what level such a filter should apply? Class, Field, both? > c) What is the syntax for the filter description? > > Let us know, with a concrete example how you will like to specify > the logical delete use case. > > Pinaki > -- View this message in context: http://n2.nabble.com/Global-%28session-based%29-data-filter-tp2269289p2386158.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
