-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Result is strange in session.scroll() (ScrollableResults)
PostPosted: Tue May 31, 2005 5:34 am 
Newbie

Joined: Tue May 31, 2005 5:08 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.