简体   繁体   中英

hql query outer join

Hi everyone I am trying to do an outer join using hql and iterate the retrieved columns to display it. the code below shows no error and also no outputs.

 <html> <body> <% try { SessionFactory sf= new Configuration().configure().buildSessionFactory(); Session s= sf.openSession(); Query e=s.createQuery("select u.*, d.* from Units u,Depts d outer join d.deptId=u.depts"); Iterator i= e.iterate(); out.println("<table>"); while(i.hasNext()) { Units l= (Units)i.next(); Depts v= (Depts)i.next();; out.println("<tr><th>"+l.getUnitId()); out.println("<th>"+v.getDeptName()); out.println("<th>"+l.getUnitName()); } } catch (Exception he) { he.printStackTrace();} %> </body> </html> 

正确的SQL是

select u.*, d.* from Units u outer join Depts d on d.deptId=u.depts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM