search

Home  >  Q&A  >  body text

java - Hibernate我用criteria查找产品名称里包含abc的产品,用了Restrictions.like,但是没结果

//查找产品名称里包含abc的产品

Criteria criteria = session.createCriteria(Product.class);
criteria.add(Restrictions.like("name", "%abc%"));
l = criteria.list();

product表里明明有名称包含abc的产品。

ringa_leeringa_lee2850 days ago631

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:20:31

    The reason why the query cannot be found is because the Oracle database is case-sensitive by default.

    Solution:

    criteria.add(Restrictions.like("name", "%abc%").ignoreCase());

    reply
    0
  • Cancelreply