如何通过示例使用休眠查询来搜索 Id?

how to search an Id using hibernate query by example?

嗨,我有以下 class

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

Version properties, identifiers and associations are ignored. By default, null valued properties are excluded.