嗨,我有以下课程

public class Label
    {
    private Long TableId;
    private Long Id;
    private String LabelName;
    //getters and setters for corresponding fields
    }

我应该在多个领域动态搜索
我遇到了hibernate逐例查询构造我的代码看起来像
Label bean =new Label();
if(Id!=null)
{
       bean.setId(Id);
}
if(LabeName!=null)
{
bean.setLabelName(LabelName)
}
    System.out.println(bean.toString());
            Example exampleObject=Example.create(bean).ignoreCase();
             criteria=currentSessionObj.createCriteria(Label.class).add(exampleObject);
             retObjects=criteria.list();

当我在LabelName字段中搜索时,当我试图按id搜索时,得到的是意外的结果
我浏览了很多论坛,但都找不到我想要的东西,请帮助我
如何处理这个问题?

最佳答案

the documentation
将忽略版本属性、标识符和关联。默认情况下,将排除空值属性。

10-07 13:52
查看更多