Query query = session.createQuery("select t,c from Cat as c,Custom as t where c.sex = :sex and c.id = t.id");
query.setCharacter("sex", 'F');
for (Iterator it = query.iterate(); it.hasNext(); ) {
Object[] queryArray = (Object[])it.next();
Cat cat = ( Cat )queryArray[1];
Custom custom = ( Custom) queryArray[0];
out.println("<p>Female Cat: " + cat.getName()+"</p>");
out.println("<p>Custom: " + custom.getName()+"</p>");
}
t,c的顺序,决定对象在queryArray中的顺序;
本文地址:http://com.8s8s.com/it/it13042.htm