String hql="from table1" 首先你要明白这句查询是什么意思,等价于sql="select * from table1"
查出来的是List。List里面存着多个table1对象。
String hql="from table1,table2" 你见过这么写的sql么?如果从两个表中查的话,都是做关联的,需要有条件的。例如select a.*from table1 a,table2 b where a.id=b.id 这句是根据id关联查询table1表中的数据。而对象是不可以这么用的,要想用到关联,必须配置对象之间的关系才可以
from table1 返回的结果不一定是一个对象,那要看你表中有多少数据了,如果只有一条数据 那就是一个对象了。
from table1,table2 这个查询不知道是什么结果,感觉这个查询语句不对。
String hql="from table1" 单条记录是对象,多条记录是集合,
String hql="from table1,table2" 写法是错误的,hql语句只能够是对(对象或者是对象集合进行操作)