I've seen this happen when there are no active conditions on the Criteria.
Specifically, I've seen it happen in Example criteria when the only attributes set on the Example class were either associations or the identifier property. Example criteria ignore both of these, and the generated query includes the "where (1=1)" condition.
If you're using Example criteria, you may want to check out the "Example Criteria" section of the "Criteria Queries" chapter of the Hibernate reference documentation. It describes how to get around this behavior for associations. A similar approach works for identifiers as well.
|