-->
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.  [ 3 posts ] 
Author Message
 Post subject: Looping out result from select query
PostPosted: Fri May 28, 2004 5:41 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Hey,


I got a select query but for some reason I can't print out the result. What am I missing?

Code:
Query q = session.createQuery("SELECT c.customerTPK.customerno "
      + "FROM net.sf.hibernate.CustomerT c "
      + "WHERE c.customerTPK.customerno='1397549'");
      
      List list = q.list();
      
         
            
      
      System.out.println("Found " + list.size() + " matching search criteria\n");
      
      System.out.println("JOIN OF CUSTOMERORDER & CUSTOMERORDERLINES");
      System.out.println("------------------------------------------");   
                  
      for (Iterator i = list.iterator(); i.hasNext();) {
         Object[] obj = (Object[]) i.next();
         String s = (String) obj[0];
         System.out.println(s);

            }



Br. Newman


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 5:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You don't get an Object[] if you just query for a single value, you get a list of values only. Use a debugger.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 6:05 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Thanks michael for the help. It works fine after deleting the [].


// Newman


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.