实体类 InfoFIle.java private Long id; private String fileId; private String title; private String subtitle; private Integer filetype; private Date updatetime; private String author; InfoFileOther.java private Long id; private Long clicknum; private Long downloadnum; private String fileId; private String varchar1; private String varchar2; private String varchar3; String hql =" from InfoFile as a , InfoFileOther as b where a.fileId = b.fileId "; hql中select a.id,b,id from .....返回的是Object[], 一个对象数组 因此这里有一种方法可以得到表连接返回的数据 list = this.getHibernateTemplate().find(hql); if(list != null){ Iterator it =list.iterator(); while(it.hasNext()){ Object[] o =(Object[])it.next(); InfoFile info =(InfoFile)o[0]; //得到InfoFile对象 InfoFileOther ifo=(InfoFileOther)o[1]; //得到InfoFileOther System.out.println(info.getId()); //对数据进行操作 } }
http://blog.csdn.net/guliangliang/archive/2010/05/26/5625475.aspx
作者:许强1. 本博客中的文章均是个人在学习和项目开发中总结。其中难免存在不足之处 ,欢迎留言指正。 2. 本文版权归作者和博客园共有,转载时,请保留本文链接。
1. 本博客中的文章均是个人在学习和项目开发中总结。其中难免存在不足之处 ,欢迎留言指正。 2. 本文版权归作者和博客园共有,转载时,请保留本文链接。