I have a problem about session.scroll();
when use
Code:
select new User(x,x) from User
, the return Object is the first column that type is 'String' ,not 'User' class , it's so strange.
but in hibernate 2.1 ,the return type is 'User' class .
Thanks
Hibernate version: 3.0.5
Mapping documents:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="User" table="User">
<cache usage="read-write"/>
<id name="userID" type="string" column="user_id" length="20">
<generator class="assigned"/>
</id>
<property name="name" type="string" column="name" length="20"/>
<property name="password" type="string" column="password" length="20"/>
<property name="email" type="string" column="email" length="30"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
String sql="select new User(userID,name) from User";
List result=new ArrayList();
ScrollableResults srs= session.createQuery(sql).scroll();
while (srs.next()) {
System.out.println(srs.get(0));
}
Full stack trace of any exception that occurs:none
Name and version of the database you are using:
mysql 4.1
The generated SQL (show_sql=true):
Hibernate: select user0_.user_id as col_0_0_, user0_.name as col_1_0_ from User user0_
Debug level Hibernate log excerpt:none