hibernate return only one record

jaggernat
jaggernat used Ask the Experts™
on
hi guys

this is my hibernate xml
<hibernate-mapping>

            <class name="com.aoc.judiciary.framework.ValueObjects.TestVO"   table="FMT_CASEADR">
            <id name="userId" column="ATTYID">
                  <generator class="native"/>
            </id>
<component name="caseInfo" class="com.aoc.judiciary.framework.ValueObjects.TestReturnVO">
      <property name="docketnumber" column="ATTYCASESEQNO"/>
      <property name="casetitle" column="ATTYCASESTREET"/>
      <property name="county" column="ATTYCASECITY"/>
</component>
      </class>

<sql-query name="getParties">
    <return alias="ResultSet" class="com.aoc.judiciary.framework.ValueObjects.TestVO"/>
  Select * from DBWD.FMT_CASEADR WHERE ATTYID = ?
</sql-query>

</hibernate-mapping>



and in my java i am iterating the list like this

 Query q = session.getNamedQuery("getParties");
                   q.setString(0,userId);
                   List list = q.list();
                   System.out.println("list Length" +list.size());
for (int i = 1; i < list.size(); i++) {
                         TestVO resultSet = (TestVO) list.get(i);
                        System.out.println("Docketnumber:" + resultSet.getCaseInfo().getDocketnumber());
                        System.out.println("Casetitle:" + resultSet.getCaseInfo().getCasetitle());
                        System.out.println("County:" + resultSet.getCaseInfo().getCounty());
                        
                  }


the query " Select * from DBWD.FMT_CASEADR WHERE ATTYID = ?"  retrieves two records from the table,although
System.out.println() statements show only the first record and not the second one.

any idea why this is hapenning

thanks
J
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
The first index in a list is 0, so you have to write:

for (int i = 0; i < list.size(); i++) {

Author

Commented:
thanks

Commented:
You're welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial