Hiya, I'm sort a newbie when it comes to hibernate so I'm going to try to ask my question as clearly as possible. I wanna execute following query as hibernate query .
<sql-query name="updateINFO">
update
info
set
status_id = 2
where
pid = :i
</sql-query>
Now i is a dynamic value, so sometimes I'll pass 1 sometimes 1000, actually I'll iterate trough list and do the query for every item in the list, you get my point. Now here is my part of java calling execution of this query ..
for(int i=0; i<list.size(); i++)
{
Query query = session.getNamedQuery("updateINFO").setParameter("pid", list.get(i));
}
Is there something wrong with this approach ? thank you
I already have created list of type Long and I get list items from another query
List<Long> list = null;
Query query = session.getNamedQuery("endDateChecker");
list = query.list();
here is my method :
public List<Long> I need findItemByPIdEndDate() throws Exception {
List<Long> list = null;
try{
Session session = sessionFactory.getCurrentSession();
Query query = session.getNamedQuery("endDateChecker");
list = query.list();
for (Long listItem : list) {
Query query1 = session.getNamedQuery("updateINFO")
.setParameter("in",listItem);
}
}catch (HibernateException e){
throw new DataAccessException(e.getMessage());
}
return list;
}