I can query by example with the following code perfectly; except when the
primary key (ID) is the only one set. Then the where clause read "Where
1=1" (1 being the unique ID). When the example object only has the
ID set it loads all entries in the table. Is there something else I need
to do.
//////////////////////
////////////////////
this.courtCase.setID(caseID);
this.courtCase.setSequence(sequence);
this.courtCase.setYear(year);
this.courtCase.setType(type);
Example example =
Example.create(this.courtCase);
example.excludeZeroes(); example.excludeProperty("createdDate"); example.excludeProperty("changedDate"); example.excludeProperty("sealed"); example.excludeProperty("advanceWarningSent"); example.excludeProperty("exceedsMaxNumberOfWarnings"); example.excludeProperty("domesticViolence"); this.courtCase = (CourtCase) session.createCriteria(CourtCase.class) .add(example) .uniqueResult(); //////////////////////////
//////////////////////////
//////////////////////
If ID is not null; sequence, year and type will be null. If ID is
null the other three will not be null. When ID is null and sequence, year
and type or set it gets one courtCase (these three constitute the number).
But when ID is set and the others are null it loads all entries in the
table.
Is there something I need to set.
|
- [Hibernate] Problem with query-by-example on primary-key Robb Greathouse
- Re: [Hibernate] Problem with query-by-example on pri... Emmanuel Bernard