Regular expression with criteria

后端 未结 1 1515
感动是毒
感动是毒 2021-01-22 17:46

I have a table in which certain words or word groups are stored. I want to select entries which start with an uppercase letter, cointain no space and contain only letters. My SQ

相关标签:
1条回答
  • 2021-01-22 18:30

    Try this:

    List words = session.createCriteria(Word.class)
    .setProjection(Projections.property("word"))
    .add(Restrictions.and(Restrictions.gt("w_id",100), Restrictions.sqlRestriction(word REGEXP '^[A-Z][A-Za-z]*$')))
    .setMaxResults(2000).list();
    
    0 讨论(0)
提交回复
热议问题