Hi,
Am new to hibernate. This is my mapping for an Entity called Appointment
Code:
<hibernate-mapping
package="entity">
<class name="Appointment" >
<id name="id" column="id" type="integer">
<generator class="identity" />
</id>
<property name="customerid" />
<property name="phone" />
<property name="complain" />
<property name="appointmentdatetime" />
<property name="reminder" />
<property name="ogm" />
<property name="status" />
</class>
</hibernate-mapping>
I also have the corresponding appointment table in my DB. My application should retrieve all appointments from this table every 30 seconds. The appointment table is updated by an external source. This is the body of my query function
Code:
Session session = sessionFactory.openSession();
Query query = session.createQuery("from Appointment as a where a.reminder between :P_start and :P_end");
if(start==null)
start=Calendar.getInstance();
query.setCalendar("P_start", start);
Calendar end=(Calendar)start.clone();
end.set(Calendar.HOUR_OF_DAY, 23);
end.set(Calendar.MINUTE, 59);
end.set(Calendar.SECOND, 59);
query.setCalendar("P_end", end);
Debug.log("Quering for appointments between " + start.getTime() + " and " + end.getTime(), true);
appointments = query.list();
Iterator<Appointment> itr=appointments.iterator();
while(itr.hasNext()){
Appointment appointment=itr.next();
scheduler.addJob(appointment);
}
session.clear();
session.close();
The problem is, every time the appointment table in DB is updated, the updates are not seen when I re query using my query function. The appointment objects fields are the same as when I did the query for the first time.
Please help