Thomas,

sounds good:
https://github.com/danielsoro/deltaspike/commit/ff9a42704547a7373421400960a09b056288ca1c
?

On Fri, Jun 12, 2015 at 5:32 PM, Daniel Cunha <daniels...@gmail.com> wrote:

> +1
>
> On Fri, Jun 12, 2015 at 8:42 AM, Thomas Hug <thomas....@gmail.com> wrote:
>
>> Oooh I see... I should really find time to code here more often. Looks
>> like
>> I forgot about a lot of this code :-D
>>
>> Maybe a little refactoring might help to clean this up. E.g. moving the
>> applyRestrictions into the QueryInvocationContext (resp. into a class
>> being
>> called by the context) so it is simpler to reuse it. Being forced to
>> extend
>> QueryBuilder seems not right to me. WDYT?
>>
>>
>> On Fri, Jun 12, 2015 at 10:52 AM, Daniel Cunha <daniels...@gmail.com>
>> wrote:
>>
>> > Thomas,
>> >
>> > Sure!
>> >
>> > MethodQueryBuilder already do it. [1]
>> > I see for Delegate[2], but.. really, I don't know how to apply it here.
>> :(
>> >
>> > [1]
>> >
>> >
>> https://github.com/danielsoro/deltaspike/blob/applyRestrictions/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java#L48
>> >
>> > [2]
>> >
>> >
>> https://github.com/danielsoro/deltaspike/blob/applyRestrictions/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/DelegateQueryBuilder.java
>> >
>> > On Fri, Jun 12, 2015 at 4:39 AM, Thomas Hug <thomas....@gmail.com>
>> wrote:
>> >
>> > > Thanks Daniel for checking! Different reason it doesn't work than I
>> had
>> > in
>> > > memory :-)
>> > > I think we should go for a general solution and not just for
>> > > EntityRepository methods, @Query metadata should be considered for any
>> > > method expression. The place to change this is probably somewhere in
>> > > Delegate- and MethodQueryBuilder.
>> > >
>> > > On Fri, Jun 12, 2015 at 4:19 AM, Daniel Cunha <daniels...@gmail.com>
>> > > wrote:
>> > >
>> > > > Thomas,
>> > > >
>> > > > you're right, not work.
>> > > > I changed and works now[1], but I don't know if this is the better
>> way
>> > to
>> > > > fix it.
>> > > >
>> > > >
>> > > >
>> > >
>> >
>> https://github.com/danielsoro/deltaspike/commit/bb02f14731e9c7fd5d20c255bae2a2033617a9b8
>> > > >
>> > > > On Thu, Jun 11, 2015 at 4:11 PM, Thomas Hug <thomas....@gmail.com>
>> > > wrote:
>> > > >
>> > > > > Using the @Query(hints...) is the place to set the hints with DS
>> > Data.
>> > > > > Unfortunately (hope my memory isn't wrong) this currently doesn't
>> > work
>> > > > with
>> > > > > a method expression. As soon as there's a @Query it's not
>> considered
>> > a
>> > > > > method expression anymore.
>> > > > >
>> > > > > Should not be too difficult to change - and should be changed as
>> the
>> > > > sample
>> > > > > from Daniel makes totally sense :-) Will check this tomorrow and
>> > > create a
>> > > > > JIRA issue.
>> > > > >
>> > > > >
>> > > > >
>> > > > > On Thu, Jun 11, 2015 at 5:42 PM, Daniel Cunha <
>> daniels...@gmail.com>
>> > > > > wrote:
>> > > > >
>> > > > > > Hmm..
>> > > > > >
>> > > > > > so, that's should work:
>> > > > > >
>> > > > > > ```
>> > > > > > @Repository
>> > > > > > public interface SimpleRepository extends
>> EntityRepository<Simple,
>> > > > Long>
>> > > > > > {
>> > > > > >
>> > > > > >     @Override
>> > > > > >     @Query(hints = {@QueryHint(name =
>> > > > > "javax.persistence.cache.storeMode",
>> > > > > > value = BYPASS)})
>> > > > > >     List<Simple> findAll();
>> > > > > > }
>> > > > > > ```
>> > > > > >
>> > > > > > On Thu, Jun 11, 2015 at 11:53 AM, akm <ameh...@ford.com> wrote:
>> > > > > >
>> > > > > > > Thanks for the reply.
>> > > > > > >
>> > > > > > > We are creating a framework that all our enterprise
>> applications
>> > > will
>> > > > > be
>> > > > > > > using; so I am looking for a generic solution that I can add
>> in a
>> > > > > > abstract
>> > > > > > > class that then all entities can use.
>> > > > > > > Basically looking for something like just adding a hint to the
>> > > > current
>> > > > > > > AbstractEntityRepository's findAll.
>> > > > > > > In the solution you mention all the applications would have to
>> > > > > implement
>> > > > > > > the
>> > > > > > > findAll for all the entities.
>> > > > > > >
>> > > > > > > What I have currently is the below solution, but now the
>> > enterprise
>> > > > > > > framework would have to implement this for all the find
>> methods
>> > > > > provided
>> > > > > > by
>> > > > > > > the DeltaSpike repository which leads to maintenance issues
>> and
>> > > thus
>> > > > > > > negates
>> > > > > > > a lot of positives that DeltaSpike would provide us.
>> > > > > > >
>> > > > > > > *Current solution -*
>> > > > > > > public abstract class MyBaseEntityCrudRepository<ENTITY, PK
>> > extends
>> > > > > > > Serializable>
>> > > > > > > extends AbstractEntityRepository<ENTITY, Serializable>
>> implements
>> > > > > > > Deactivatable {
>> > > > > > >
>> > > > > > >     public List<ENTITY> findAllFromDatabase() {
>> > > > > > >
>> > > > > > >         CriteriaQuery<ENTITY> query = this.criteriaQuery();
>> > > > > > >         Root<ENTITY> root = query.from(entityClass());
>> > > > > > >         query = query.select(root);
>> > > > > > >         TypedQuery<ENTITY> typedQuery =
>> > > > > > > this.entityManager().createQuery(query);
>> > > > > > >
>> >  typedQuery.setHint("javax.persistence.cache.retrieveMode",
>> > > > > > > CacheRetrieveMode.BYPASS);
>> > > > > > >
>> > > > > > >         return typedQuery.getResultList();
>> > > > > > >
>> > > > > > >     }
>> > > > > > >
>> > > > > > >
>> > > > > > > *I am looking for something easier method to add like -*
>> > > > > > >     /**
>> > > > > > >      * @see
>> > > org.apache.deltaspike.data.api.EntityRepository#findAll()
>> > > > > > >      */
>> > > > > > >     @Override
>> > > > > > >     @QueryHint("javax.persistence.cache.storeMode",
>> > > > > > > CacheRetrieveMode.BYPASS)
>> > > > > > >     public List<ENTITY> findAll() {
>> > > > > > >      return super.findAll();
>> > > > > > >     }
>> > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > > > --
>> > > > > > > View this message in context:
>> > > > > > >
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/DeltaSpike-Data-Module-Repository-tp4660831p4660840.html
>> > > > > > > Sent from the Apache DeltaSpike Incubator Discussions mailing
>> > list
>> > > > > > archive
>> > > > > > > at Nabble.com.
>> > > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > > --
>> > > > > > Best regard,
>> > > > > > Daniel Cunha (soro)
>> > > > > >
>> > > > >
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > Best regard,
>> > > > Daniel Cunha (soro)
>> > > >
>> > >
>> >
>> >
>> >
>> > --
>> > Best regard,
>> > Daniel Cunha (soro)
>> >
>>
>
>
>
> --
> Best regard,
> Daniel Cunha (soro)
>



-- 
Best regard,
Daniel Cunha (soro)

Reply via email to