需要帮助来创建hibernate标准吗
我不熟悉hibernate标准。如果我在下面的代码中出错,请纠正我需要帮助来创建hibernate标准吗,hibernate,criteria,Hibernate,Criteria,我不熟悉hibernate标准。如果我在下面的代码中出错,请纠正我 Criteria c = getSessionFactory().getCurrentSession().createCriteria(JdwCustomerTlrdRef.class); c.add(Restrictions.ilike("operations_spec", "%AAL%")); List<JdwCustomerTlrdRef> customerTl
Criteria c = getSessionFactory().getCurrentSession().createCriteria(JdwCustomerTlrdRef.class);
c.add(Restrictions.ilike("operations_spec", "%AAL%"));
List<JdwCustomerTlrdRef> customerTlrdRefSysId = c.list();
我对操作规范应用了限制,它将返回所有AAL客户名称。试试这个
Criteria c = getSessionFactory().getCurrentSession().createCriteria(JdwCustomerTlrdRef.class);
如果你想找到准确的AAL那么
c.add(Restrictions.eq("operations_spec", "AAL" ));
或者,如果您希望所有拥有AAL的客户都在operations_spec字段中的任何位置,即ABALCD,那么
c.add(Restrictions.like("operations_spec", "AAL" , MatchMode.ANYWHERE));
还有一件事,您正在使用字段名作为操作规范,它看起来像数据库中的字段名。如果您想在标准中使用,那么应该使用属性名,如果您遵循java成员名编码实践,我认为这将是operationSpecs
如果是这种情况,则应用如下限制
c.add(Restrictions.eq("operationSpecs", "AAL" ));