但是,我们现在数据库的配置文件都没有采用延迟加载
能不能做一个新的po来吧userInfo和wapUserContentTb的数据库字段设成一个新的po来去数据呢?
下面是我的代码
package com.datacomo.mobi5.app.tf.test;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.datacomo.hibernate.HibernateSessionFactory;
import com.datacomo.hibernate.po.UserInfo;
import com.datacomo.hibernate.po.WapUserContentTb;
public class MutiTableTest{
public static void main(String args[]) {
Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
String hql = "from UserInfo u ,WapUserContentTb w where w.userId=u.userId and w.id=:Id";
Query query = session.createQuery( hql );
query.setString( "Id", "28E0A972908C6CCBE040A8C05201149D" );
List list = query.list();
tx.commit();
session.close();
System.out.println(list.get( 0 ));
for(int i =0 ;i
Object [] o = (Object[])list.get( i );
for(int j = 0; j
WapUserContentTb wap =(WapUserContentTb)o[j];
System.out.println(wap.getChangeFileName());
}
else if(o[j] instanceof UserInfo) {
UserInfo userInfo =(UserInfo)o[j];
System.out.println(userInfo.getRealName());
}
}
}
}
}