-->
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.  [ 5 posts ] 
Author Message
 Post subject: Get property values when using Query.Scroll
PostPosted: Mon Feb 02, 2004 5:54 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
I have the following .hbm.xml file ( part of it ):

<property name="classCode" column="classCode" type="string" length="250" not-null="true" unique="false"/>

<property name="companyCode" column="companyCode" type="string" length="250" not-null="true" unique="false"/>

<property name="fundCode" column="fundCode" type="string" length="250" not-null="true" unique="false"/>

<property name="fundSponsor" column="fundSponsor" type="string" length="250" not-null="true" unique="false"/>

And I have this query to lookup in the database, and this code to check
up the database for this object :

sql = "SELECT i.companyCode, i.fundSponsor FROM abpro.beans.Funds2 i WHERE i.fundCode = 'B91A' AND i.classCode = 'A'";

hql = session.createQuery(sql);
results = hql.scroll();

I can get out the types of the properties with :

results.getType(0).getName());
results.getType(1).getName());

BUT HOW DO I GET THE VALUES OF THE PROPERTIES ?

In this case :

companyCode should be ASEA //according to value in the database
fundSponsor should be NONE //according to value in the database

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 6:20 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Code:
results.get(i);

where i is the number of the column (from 0)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 6:27 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
Thanks, I thought results.get(int i ) would return the i:th row in the "resultSet". Anyway, when I am using, e.g results.get(1) I get the
following Exception :

net.sf.hibernate.util.JDBCExceptionReporter - SQLException occurred
java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0EM: End of data.

I also get this Exception when trying to do

Object obj [ ] = results.get( );

Ideas ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 6:39 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Make sure that you have a valid row to process and haven't 'run off the end' of the resultset.

e.g.
Code:
results.beforeFirst();
while(results.next()) {
  System.out.println(results.get(0) + " - " + results.get(1)); 
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 6:48 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 6:16 am
Posts: 40
Location: Luxembourg
Excellent ! Many thanks for helping me. The problem was me not using the results.first ( ).

Again, thanks for Your help.


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

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.