Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in passing a string array to HQL

 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a requirement to delete some rows in the table:
delete from table where table_column in StringArray[];

Suggest me how to add all my integer elements ie,ID to a string array[] and send it to the query using HQL.by using query in hibernate.cfg.xml.
Suggest me what to write in code part to send that string array[] to HQL??

Thanks in Advance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have an array of Integers if your property is a String?

HQL allows you to bind Collections and of values using the various setPatameterList() methods.
 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for (Iterator iter = deleteList.iterator(); iter.hasNext() {

AssignmentByLetter deletingList = (AssignmentByLetter) iter.next();

int var1=deletingList.getAssignmentID();

}

My problem deletingList.getAssignmentID() is a integer and i have to take iterate deleteList and take all assignmentID's and add in to a String array or Integer Array first???
and moreover how to pass that String array[] or integer[] array to hibernate query??
Please Suggest me.
 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
Why do you have an array of Integers if your property is a String?

HQL allows you to bind Collections and of values using the various setPatameterList() methods.


Thanks for replying Paul...
Actually my requirement is as follows:

for (Iterator iter = deleteList.iterator(); iter.hasNext() {

AssignmentByLetter deletingList = (AssignmentByLetter) iter.next();

int var1=deletingList.getAssignmentID();

}

My problem deletingList.getAssignmentID() is a integer and i have to take iterate deleteList and take all assignmentID's and add in to a String array or Integer Array first???
and moreover how to pass that String array[] or integer[] array to hibernate query??
Please Suggest me.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Check out where in for a delete query.
2) alternatively load the object and delete it. You might want to look at load() or get() and delete() of org.hibernate.Session;
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Check out where in for a delete query.
2) alternatively load the object and delete it. You might want to look at load() or get() and delete() of org.hibernate.Session;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic