I am using Hibernate with JPA annotated entities and the next code which I expect to update "raw_text" field of an entity doesn't change it. How to achieve the expected behavior?
@Override
public void updatePageWithText(String pageName, String rawText) {
Session session = HibernateUtils.getInstance().openSession();
String hql = "FROM WikiPage M WHERE M.name = :name";
Query query = session.createQuery(hql);
query.setParameter("name",pageName);
WikiPage res = null;
try {
res = (WikiPage) query.list().get(0);
res.setRawText(rawText);
session.update(res);
session.flush();
}
catch (IndexOutOfBoundsException e) {}
finally {
session.close();
}
}