final String productAreaName) {
return (List<Order>) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(final Session session) {
Criteria criteria = session
.createCriteria(Order.class)
.add(Expression.sql(
"datepart(year,agreement_date)=?",
year, Hibernate.INTEGER))
.add(Expression
.sql("dbo.GetISOWeekNumberFromDate(agreement_date) between ? and ?",
new Object[] { weekFrom, weekTo },
new Type[] { Hibernate.INTEGER,
Hibernate.INTEGER }))
.addOrder(
org.hibernate.criterion.Order
.asc("salesman"))
.createCriteria("constructionType")
.add(Restrictions.not(Restrictions.ilike(
"name", "%tilleggsordre%")));
if (productAreaName != null) {
criteria.createCriteria("productArea").add(
Restrictions.eq("productArea",
productAreaName));
}
return criteria.list();
}
});
}