<pre name="code" class="java">public Data<FilmDirector> findDiectorByFilmId(Long filmId) {
Data<FilmDirector> rows = directorDao.findRows("select new FilmDirector(fd.id as id,fd.chName as chName,fd.enName as enName,fd.birthDate as birthDate,fd.birthplace as birthplace) from FilmDirector as fd inner join fd.filmList fl where fl.id=?", filmId);
return rows;
}
在hibernate中如果一对多关联,并以多的一方的参数作为条件则必须使用 <pre name="code" class="java">from FilmDirector as fd inner join fd.filmList fl where fl.id
不然会报异常,这是hibernate版本问题导致的
如果想将查询的结果封装到构造方法里面则必须使用<pre name="code" class="java">new FilmDirector(fd.id as id,fd.chName as chName,fd.enName as enName,fd.birthDate as birthDate,fd.birthplace as birthplace)