@Repository
public class JobSheetDaoImpl implements JobSheetDao {
@Autowired
private HibernateTemplate hibernateTemplate;
@Transactional
public void createJobSheet(JobSheet jobSheet) {
//to get technician who have minimum workload
String query="select * from Technician Where expertiseCompany=? "
+ "AND expertiseDevice=? AND totalJobs=(select MIN(totalJobs) "
+ "from Technician)";
//how to fire this query using hibernatetemplate ???
}
}
你必须像这样使用Hibernate会话:
SQLQuery sqlQuery = hibernateTemplate.getSession().createSQLQuery(query);
sqlQuery.setParamer(...) // set the parameters you need
List result = sqlQuery.list();