Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要帮助来创建hibernate标准吗_Hibernate_Criteria - Fatal编程技术网

需要帮助来创建hibernate标准吗

需要帮助来创建hibernate标准吗,hibernate,criteria,Hibernate,Criteria,我不熟悉hibernate标准。如果我在下面的代码中出错,请纠正我 Criteria c = getSessionFactory().getCurrentSession().createCriteria(JdwCustomerTlrdRef.class); c.add(Restrictions.ilike("operations_spec", "%AAL%")); List<JdwCustomerTlrdRef> customerTl

我不熟悉hibernate标准。如果我在下面的代码中出错,请纠正我

        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" ));