Hi Pedro, You can try that: https://github.com/apache/deltaspike/blob/master/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java#L103 https://github.com/apache/deltaspike/blob/master/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/QueryResultTest.java#L167
So, you'll create methods on your repository, something like: findByNameLikeIgnoreCase findByAssigment findByNameLikeIgnoreCaseAndAssigment So you can put your business logic on your business class. You'll call the method that you need: @Inject private RepositoryClass repository if (YOUR_LOGIC) repository.findByNameLikeIgnoreCaseAndAssigment ... To be honest, I don't know if possible to do like you was trying. I needed checking it. On Thu, Feb 25, 2016 at 2:04 PM, Pedro Belmino <[email protected]> wrote: > Daniel, > OK to return an object of type List<Person>. > > However i need return an QueryResult<Person>, because the pagination is > important for me. > > > > 2016-02-25 13:59 GMT-03:00 Daniel Cunha <[email protected]>: > > > Hi Pedro, > > > > JPA Criteria API Support sounds better for this cases: > > > http://deltaspike.apache.org/documentation/data.html#JPACriteriaAPISupport > > > > On Thu, Feb 25, 2016 at 1:50 PM, Pedro Belmino <[email protected]> > > wrote: > > > > > Hello, > > > I need construct an method that receive dynamic parameters for HQL > query > > > construct. > > > > > > For example: > > > @Repository(forEntity = Person.class) > > > public abstract class PersonCustomRepository extends > > > AbstractEntityRepository<Person, Long> { > > > > > > public QueryResult<Person> > > > findByNameLikeIgnoreCaseAndAssigment(String name, > > > Assigment assigment, @FirstResult int start, @MaxResults int pageSize){ > > > String query = "select p from person p WHERE 1 = 1 "; > > > if(name!=null&&!name.equals("")){ > > > query+= " and name = ?1 "; > > > } > > > if(assigment!=null){ > > > query+= " and assigment = ?2 "; > > > } > > > // WHAT IS NECESSARY CODE FOR RETURN paginated object of type > > > QueryResult<Person>. > > > } > > > } > > > > > > I'm doing something wrong? I do otherwise? > > > > > > -- > > > > > > > > > > > > *Pedro Belmino *System Analist > > > Laboratory of Mobile Computing and Design > > > Federal University of Ceará > > > Office: + 55 85 3366-9797 > > > E-mail: [email protected] <[email protected]> > > > > > > > > > > > -- > > Daniel Cunha > > https://twitter.com/dvlc_ > > http://www.tomitribe.com > > > > > > -- > > > > *Pedro Belmino *System Analist > Laboratory of Mobile Computing and Design > Federal University of Ceará > Office: + 55 85 3366-9797 > E-mail: [email protected] <[email protected]> > -- Daniel Cunha https://twitter.com/dvlc_ http://www.tomitribe.com
