Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to pass a string array to HQL Query

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I have a String array and i have to pass it has a parameter to Hibernate.hbm.xml file where my code looks like this:

String[] columns=new String[deleteList.size()];//String Array

Query q = session.getNamedQuery("deleteAssignmentByLetter").setParameterList("assignmentIDD",columns);//Calling the query from Hibernate.cfg.xml file

Hibernate.hbm.xml File Query:

<query name="deleteAssignmentByLetter"><![CDATA[
delete from AssignmentByLetter where assignmentID in (:assignmentIDD);
]]></query>

Please suggest me whether this is right or wrong?
How to a string array in ParameterList??

Thanks in Advance
 
Ranch Hand
Posts: 84
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi amithbn, could you post the error that it's showing?
 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Angel,

Actually till now i am just doing ant and building the project,because till now client did not told to implement it on their environment.till now build is successfull but i am confused in passing string array.

Whether i have to pass it like this to HQL or what?
columns[] or columns
Please give me suggestion just to pass a string array in the parameterlist..

Thanks in Advance
 
Angel Taveras
Ranch Hand
Posts: 84
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to your example above you have a collection. You can pass it as is, you don't have to convert it to an Array. Referring to the question at hand, you only need to now that the elements in the parametersList must be of the same type or belong to the same interface that it's known to hibernate and must match the type of the property that you're querying to. Meaning that if you are passing an array of String then the property that you're querying it's a String.

Regards,
[ December 11, 2008: Message edited by: Angel Taveras ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic