实体类
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()); //对数据进行操作
}
}