嗨,我有以下类(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 搜索时,我得到了意想不到的结果 我浏览了很多论坛,我无法得到我想要的东西,请帮助我 如何处理这个问题?
最佳答案
Version properties, identifiers and associations are ignored. By default, null valued properties are excluded.
关于java - 如何通过示例使用 hibernate 查询来搜索 Id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31356381/