Reputation: 887
This is my action:
public class TestPollAction extends ActionSupport {
private static final long serialVersionUID = 2753118140091192432L;
public String execute() {
String temp = "start";
while(!"accepted".equals(temp)) {
temp = getJobStatus("2");
System.out.println("temp: " + temp);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return SUCCESS;
}
public static String getJobStatus(String jobId) {
Session session = HibernateUtil.getSession();
String jobStatus = null;
JobBoard jobBoard = null;
try {
jobBoard = (JobBoard) session.createQuery("from " + JobBoard.class.getSimpleName() + " where jobId = :jobId )").setParameter("jobId", jobId).uniqueResult();
jobStatus = jobBoard.getStatus();
} catch (HibernateException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
session.flush();
session.close();
}
return jobStatus;
}
}
I am calling this action from postman. Then using MySQL Workbench, I am updating the database, setting the status field to "accepted" and then clicking "Apply" which commits the changes to the database.
But that System.out.println("temp: " + temp);
does not show me the updated value, it keeps showing me "start".
Upvotes: 0
Views: 19
Reputation: 887
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.11.Final</version>
</dependency>
This is the one that should be used. I had a different dependency.
Upvotes: 1