Reputation: 71
hi i have the following class
public class Label
{
private Long TableId;
private Long Id;
private String LabelName;
//getters and setters for corresponding fields
}
i was supposed to search on multiple fields dynamically i came across hibernate query by example construct my code looks like some thing
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();
when i'm searching on LabelName field i'm getting the exact response when when i tried to search by id i'm getting unexpected results i have goggled many forums i couldn't get what i want some one please help me how to deal with this issue?
Upvotes: 2
Views: 848
Reputation: 691865
From the documentation
Version properties, identifiers and associations are ignored. By default, null valued properties are excluded.
Upvotes: 1