-->
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: problem using "select *..."
PostPosted: Mon Aug 07, 2006 11:45 am 
Newbie

Joined: Wed Jul 26, 2006 10:14 am
Posts: 4
hi,

i'm trying to get an ArrayList of objects from my database.

Code:
lender.setLicenses((ArrayList)sess.createQuery("select * from "+LoanDBConstants.BANK_CL_LICENSE_TABLE+" where BNK_CL_ID='"+corrId+"'").list());


it doesn't like the * in select *, how else can i do this without using the *???

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 07, 2006 11:55 am 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Instead of using table_name you can use mapping class name in your hql.

so your line of code becomes

Code:
lender.setLicenses( (ArrayList) sess.createQuery(" from BankClLicense bcl where bcl.bnkClId = ? ").setParameter( 0, corrId ).list());


where BANK_CL_LICENSE_TABLE mapping class is BankClLicense and bnkClId is the property for the column BNK_CL_ID

However, if you want SQL itself, use createSQLQuery()

Code:
lender.setLicenses((ArrayList)sess.createSQLQuery("select * from "+LoanDBConstants.BANK_CL_LICENSE_TABLE+" where BNK_CL_ID='"+corrId+"'").list());


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 07, 2006 12:07 pm 
Newbie

Joined: Wed Jul 26, 2006 10:14 am
Posts: 4
well i used the SQLquery and it works...thanks...


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.