Unfortunately this is - with the current state of the Data module - not straight forward to add: - You might consider using a provider-specific feature like Hibernate filters (EclipseLink and OpenJPA probably provide something similar). To activate the filter, it's currently not possible to use an interceptor on repositories (that's also why your @Transactional will not work as you expect) so you'd need a wrapping bean. - On the DS Data side, we might look into something similar as Seam 2 had with restrictions on query objects ( http://docs.jboss.org/seam/latest-2.3/reference/html/framework.html#d0e8307). Definitely less powerful than filters and probably also not universally usable (e.g. hardly on named queries and native SQL) - Something we should definitely add is a better SPI to hook into various areas of DS Data.
A soft delete might be something we could add to the delete method of the EntityRepository. It's probably enough to provide an annotation which marks the filter field as well as the state it has to be set to. As usual, it would be great if you could create a JIRA ticket at https://issues.apache.org/ to keep track of improvements :-) On Sun, Aug 10, 2014 at 1:13 AM, Stan Ioan Eugen <[email protected]> wrote: > Hello, > > I'm working on a web service which uses deltaspike data and cxf to > expose a jax-rs service. My service needs to show data based on the > current user and I would like to hear your opinion on what is the best > approach to do this with deltaspike data. > > I have my repository defined like this: > > @Repository > @Transactional > public interface InvoiceRepository extends EntityRepository<Invoice, ID> { > } > > I wish that when user A calls the service, my repository should list > only invoices that he owns. The Invoice entity has a owner field > (links to the account, and to the user) > > What is the best approach that I should use? I'm using Shiro for > security. My idea so far is to make a custom EntityRepository > implementation that will get the current user and filer (don't know > exactly how yet) by it. > > I've searched for a solution to Spring Data [1], but it seems they > haven't implemented it yet. Are there plans for Deltaspike Data to > support such a feature? > > Regards, > > [1] https://jira.spring.io/browse/DATACMNS-293 > > > -- > Ioan Eugen Stan / ieugen.ro >
