-->
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: Deletion approach using named query
PostPosted: Fri Jun 09, 2006 2:25 am 
Regular
Regular

Joined: Mon May 08, 2006 6:00 am
Posts: 53
Location: India
Hi,

I have following delete query.

delete from userid where useraccontno in (1,2,3,4,5);

I am looking for a nice solution to implement above using named query.

Parameters of this queries are the one specified in brackes (1,2,3,4,5), using "in" SQL clause.

For this I am defining above query in .hbm file

<query name="delete">
delete from userid where useraccontno in (:accountNo);
<query>

Now my problem comes while setting the problem for variable "accountNo"
If I set
getnamedQuery("delete").setInteger("accoutNo",1) then it works

but
If I set
getnamedQuery("delete").setString("accoutNo","1,2,3,4") then it doesnt work

Hope I was clear enough to expalin the problem any solution please

Thanks

Sudhir


Top
 Profile  
 
 Post subject: Deletion Approach to named query
PostPosted: Fri Jun 09, 2006 4:15 am 
Newbie

Joined: Fri Jul 15, 2005 12:42 am
Posts: 18
Sudhir..

This should work
String[] s = {"1","2","3","4"}
getnamedQuery("delete").setParameterList("accoutNo",s)

Note: s can be a list or an [] but should never be empty throws an exception.
regards
Dilip
--------


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.