hibernate怎么进行多表查询??? (50分)

  • 主题发起人 主题发起人 WorldCreater
  • 开始时间 开始时间
W

WorldCreater

Unregistered / Unconfirmed
GUEST, unregistred user!
hibernate怎么进行多表查询???
 
这是用hibernate查询单表的例子:
Session dbSession = null;
try {
SessionFactory sessionFactory = new Configuration().config().buildSessionFactory();
dbSession = sessionFactory.openSession ();
Transaction transaction = dbSession.begin
Transaction();
StringBuffer hql = new StringBuffer (“from MemberTable where Name=’”);
hql.append (“userName”);
hql.append(“’”);
Query query = dbSession.createQuery (hql.toString());
query.setFirstResult(0);
query.setMaxResults(1);
transaction.commit();
Iterator memberIterator = query.iterate();
if (memberIterator.hasNext()) {
MemberTable memberObj = (MemberTable) memberIterator.next();//要是查询多表的话,在这里该怎么做?
System.out.println (memberObj.getPassword);
}
} catch (Exception e) {
System.err.println ;
} finally {
try { dbSession.close();
} catch (Exception e) {}
}
 
后退
顶部