Skip to content

Instantly share code, notes, and snippets.

@ripper2hl
Last active February 17, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ripper2hl/4875f55fefdd8640c507 to your computer and use it in GitHub Desktop.
Save ripper2hl/4875f55fefdd8640c507 to your computer and use it in GitHub Desktop.
Hibernate Criteria to Lucene Full Text Query
@Transactional(readOnly = true)
public List<Cliente> example(Cliente cliente){
Session session = em.unwrap(Session.class);
FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( session );
Criteria criteria = fullTextSession.createCriteria(Cliente.class);
Example example = Example.create(cliente)
.excludeZeroes()
.ignoreCase()
.enableLike(MatchMode.ANYWHERE)
.excludeProperty("idCliente");
criteria.add(example);
List result = criteria.list();
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment