嗨,我有以下课程
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搜索时,我得到了确切的答案我得到了意想不到的结果 我有许多论坛,我无法得到我想要的东西,请帮助我 如何处理这个问题?