-->
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.  [ 2 posts ] 
Author Message
 Post subject: How can I select all columns in map
PostPosted: Wed Aug 25, 2010 4:45 am 
Newbie

Joined: Wed Aug 25, 2010 4:35 am
Posts: 8
Hi,
I want to select all columns of a table in MAP (dynamic map entity)

I know the method of selecting columns in map

e.g.,
select new map(studentname as name,enroll as enroll,subject as sub) from student

but I want something like as we have in SQL

select * from student;

any method of selecting all columns in MAP without specifying the column name

Thanks in Advance
Asit Jaiswal


Top
 Profile  
 
 Post subject: Re: How can I select all columns in map
PostPosted: Thu Aug 26, 2010 2:46 am 
Newbie

Joined: Wed Aug 25, 2010 4:35 am
Posts: 8
I have solved that problem

we can select all columns of table using this simple syntax

Code:
l=dynamicsession.createQuery("from "+tablename).list();


it returns list of Hashmap object where column names are keys.

l is the object of java.util.List

Code:
for(int i=0;i<l.size();i++){
      Set keys = ((Map)l.get(i)).keySet();
      int size = keys.size();
      Iterator it = keys.iterator();
      for(int j=0;j<size-1;j++)
      System.out.println(((Map)l.get(i)).get(it.next().toString()));
      
      }


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