查询结果从多张表中找出非常普遍,该例子教你实现查询结果bean的实现
1 插寻结果bean,A的属性a、b来源于已影射的bean M,N
class A
{
String a,b;
public A(String a,String b)
{
this.a=a;
thia.b=b;
}
}
2 编写查询方法
Query q;
List l = null;
q = session.createQuery("select new A(M.a,N.b) from M as M,N as N where M.id=N.id");
3 资源载入A
<import class="package.A"/>