Hi, I have the following class
Code:
class File {
List<Document> documents;
List<Invoice> invoices;
}
properly mapped, actually Its far more complex but I want to keep it simple to explain my problem.
Document and Invoice classes has a "
notes" property. I want to search all the files where the notes of documents
OR the notes of invoices are equals to some value. The whole is a more complex query and I cant use HQL.
Code:
Criteria criteria = session.createCriteria("File");
Criteria criteriaDocument = criteria.createCriteria("Document");
Criteria criteriaInvoice = criteria.createCriteria("Invoice");
criteriaDocument.add(Restriction.ilike("notes","somevalue"));
criteriaInvoice.add(Restriction.ilike("notes","somevalue"));
I cant use Restriction.or() because its criteria aware. The SQL generated is "document.notes = 'something'
AND invoice.notes='something'" but I cant find a way to do some OR between those criterias.