This should be very simple, but i've tried it in several different ways and still can't get it right....
What i need is to get an object's collection and then depending on a condition such as
Code:
if(currentTime >= lap){
updating an object's field.
Seems that there is a problem with the persistance or/and the Session, because every time there's more than one Escalation object in the it Iterator, it only reaches the first object and then stops.....No error messages, no Exceptions thrown, just nothing!!!???
Here's the code:
Code:
try{
session = sf.openSession();
Query query = session.createQuery("from attend.entity.Escalation esc where esc.iniTime <= " + ini + " and esc.endTime >= " + ini + " and esc.on = 'y' and esc.server = '" + paramValue + "' order by esc.order asc");
Iterator it = query.iterate();
while(it.hasNext()){
Escalation esc = (Escalation)it.next();
long currentTime = date.getTime();
long lap = esc.getLastExe() + (esc.getLap() * 60 * 1000);
if(currentTime >= lap){
try{
esc.setLastExe(date.getTime());
session.saveOrUpdate(esc);
session.flush();
session.connection().commit();
}
catch (SQLException sqle) {
System.out.println("SQLException in class attend.Escale: errors in actualizing lastExe field ->" + sqle.getMessage());
}
catch (HibernateException he) {
System.out.println("HibernateException in class attend.Escale: errors in actualizing lastExe field ->" + he.getMessage());
}
}
}
session.close();
}
catch (HibernateException he) {
System.out.println("HibernateException in class attend.Escale: " + he.getMessage());
}
and here's is the schema:
Code:
<class name="attend.entity.Escalation" table="sys_escalation">
<id name="code" column="esc_esccod" type="string">
<generator class="assigned" />
</id>
<property name="obj" column="esc_escobj" type="string" />
<property name="from" column="esc_escfrm" type="string" />
<property name="where" column="esc_escwhr" type="string" />
<property name="server" column="esc_escsrv" type="string" />
<property name="order" column="esc_escord" type="int" />
<property name="iniTime" column="esc_initme" type="int" />
<property name="endTime" column="esc_endtme" type="int" />
<property name="lap" column="esc_esclap" type="int" />
<property name="lastExe" column="esc_lstexe" type="long" />
<property name="on" column="esc_escaon" type="string" />
<property name="observation" column="esc_escobs" type="string" />
<property name="active" column="esc_active" type="string" />
</class>
I guess there's something wrong with the use/order of the Session's methods. Please help
:-)