How to do in HQL a query by ID using the LIKE operator?

1

How do I do this query in HQL?

select * from entidadeQualquer where  id::text like '%12';

I've tried the code below but it did not work:

select c from entidadeQualquerc  where  c.id like '%12';
    
asked by anonymous 16.02.2018 / 20:36

1 answer

1

Without the entity code you can not be sure, but you can try something like this:

String hql = "select c from entidadeQualquer c where CAST(id as text) like :id";

And to set the parameter:

Query query = em.createQuery(hql);
query.setParameter("id", "%12");
List<EntidadeQualquer> lista = query.getResultList()
    
16.02.2018 / 20:43