我有4个表格
- Titles having the following fields, id (PK), Name, AuthorId(FK) & PublishedId(FK)
- Author having id(FK), Author Name & Contact Details
- Publisher having, id(PK), Publisher Name & RegionId(FK)
- Region having, id(PK), Region Name, Published Date & Published Cost.
现在我认为,我接受。
Author Name, and my code looks like
SearchTemplate _tempTemplate = new SearchTemplate(); Criterion criterion = null;
if (rcValue.getOperator().equalsIgnoreCase("like")) { criterion = Restrictions.like(rcValue.getDisplayName(), rcValue.getOperandValue()); } else if (rcValue.getOperator().equalsIgnoreCase("is")) { criterion = Restrictions.eq(rcValue.getDisplayName(), rcValue.getOperandValue()); } else if (rcValue.getOperator().equalsIgnoreCase("not")) { criterion = Restrictions.ne(rcValue.getDisplayName(), rcValue.getOperandValue()); } _tempTemplate.addCriterion(criterion);
When I search for Name, I get the right results, but when I search for my Author Name, what do I need to change in my above code?
2.When I search of Published Date, what do I need to change, because its a multi-table search, if its SQL I can easily write it, but using Hibernate now and with an implementation of SearchTemplate
/*The SearchTemplate is used to pass search parameters to the DAO layer.
*
* By having all the search parameters in one place (the SearchTemplate),
* we prevents combinatory explosion of find method signatures in the DAO/Service layer.
* This leads to more stable DAO/Service interfaces as you can add search parameters to the
* SearchTemplate without adding new methods to your interfaces.
*
* A SearchTemplate helps you drive your search in the following areas:
*/
谁能帮助?