deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Cunha <daniels...@gmail.com>
Subject Re: Extends AbstractEntityRepository Create custom methods
Date Thu, 25 Feb 2016 16:59:05 GMT
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 <pedrobelmino@gmail.com>
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: pedrobelmino@great.ufc.br <franciscobernardo@great.ufc.br>
>



-- 
Daniel Cunha
https://twitter.com/dvlc_
http://www.tomitribe.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message