Re: DeltaSpike Data Module Repository
Yep looks better to me. I'd be rather careful though putting this into the API (not in that form as it's not clear what it does). If we see a case later we can still expose it. On Sun, Jun 14, 2015 at 8:15 AM, Daniel Cunha daniels...@gmail.com wrote: 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 EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY typedQuery = this.entityManager().createQuery(query);
Re: DeltaSpike Data Module Repository
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 EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY 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)
Re: DeltaSpike Data Module Repository
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 EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY 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
Re: DeltaSpike Data Module Repository
+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 EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY findAll() { return super.findAll(); } -- View this message in context:
Re: DeltaSpike Data Module Repository
Ops, I wanted to say: NativeNamedQuery and the method should return a list, not a entity. I used a sample of the documentation and add the hint to show my example. (I'm fixing it in documentation now) On Thu, Jun 11, 2015 at 11:57 AM, Daniel Cunha daniels...@gmail.com wrote: Hi Akm, Maybe, you can do something like: ``` public abstract class PersonRepository extends AbstractEntityRepositoryPerson, Long { public Person findBySSN(String ssn) { return typedQuery(select p from Person p where p.ssn = ?1) .setParameter(1, ssn) .setHint(xpto,xpto-value) .getResultList(); } } ``` Or, you can use NamedQuery/NativeQuery. We've this two solutions, ATM. (If I remember well, please DS guys, talk more if I forget something) If you have some another idea, please, share it and maybe we can discuss and implement it or you can present a some solution with a patch/Pull Request. On Thu, Jun 11, 2015 at 10:37 AM, akm ameh...@ford.com wrote: We are piloting DeltaSpike Data Module in our enterprise. Our requirements are to add a query hint to bypass cache for the find methods since most of our applications need to get the latest data from the database as the records may be directly inserted or updated in the database. I cannot find a way to add hints to the repository find method. Is there a way to do this? Thanks for the help. -- View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/DeltaSpike-Data-Module-Repository-tp4660831.html Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com. -- Best regard, Daniel Cunha (soro) -- Best regard, Daniel Cunha (soro)
Re: DeltaSpike Data Module Repository
you also can do: http://deltaspike.apache.org/documentation/data.html#QueryOptions21 On Thu, Jun 11, 2015 at 12:02 PM, Daniel Cunha daniels...@gmail.com wrote: Ops, I wanted to say: NativeNamedQuery and the method should return a list, not a entity. I used a sample of the documentation and add the hint to show my example. (I'm fixing it in documentation now) On Thu, Jun 11, 2015 at 11:57 AM, Daniel Cunha daniels...@gmail.com wrote: Hi Akm, Maybe, you can do something like: ``` public abstract class PersonRepository extends AbstractEntityRepositoryPerson, Long { public Person findBySSN(String ssn) { return typedQuery(select p from Person p where p.ssn = ?1) .setParameter(1, ssn) .setHint(xpto,xpto-value) .getResultList(); } } ``` Or, you can use NamedQuery/NativeQuery. We've this two solutions, ATM. (If I remember well, please DS guys, talk more if I forget something) If you have some another idea, please, share it and maybe we can discuss and implement it or you can present a some solution with a patch/Pull Request. On Thu, Jun 11, 2015 at 10:37 AM, akm ameh...@ford.com wrote: We are piloting DeltaSpike Data Module in our enterprise. Our requirements are to add a query hint to bypass cache for the find methods since most of our applications need to get the latest data from the database as the records may be directly inserted or updated in the database. I cannot find a way to add hints to the repository find method. Is there a way to do this? Thanks for the help. -- View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/DeltaSpike-Data-Module-Repository-tp4660831.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)
Re: DeltaSpike Data Module Repository
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 EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY 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)
Re: DeltaSpike Data Module Repository
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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY 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.
Re: DeltaSpike Data Module Repository
Hmm.. so, that's should work: ``` @Repository public interface SimpleRepository extends EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY 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)
Re: DeltaSpike Data Module Repository
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 EntityRepositorySimple, Long { @Override @Query(hints = {@QueryHint(name = javax.persistence.cache.storeMode, value = BYPASS)}) ListSimple 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 MyBaseEntityCrudRepositoryENTITY, PK extends Serializable extends AbstractEntityRepositoryENTITY, Serializable implements Deactivatable { public ListENTITY findAllFromDatabase() { CriteriaQueryENTITY query = this.criteriaQuery(); RootENTITY root = query.from(entityClass()); query = query.select(root); TypedQueryENTITY 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 ListENTITY 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)