Query propertyQuery = em.createNativeQuery("SELECT MESSAGE_ID, PROPERTIES_ID FROM MESSAGE_PROPERTY");
em.getTransaction().commit();
DelegatingResultList propertyNameList = (DelegatingResultList) propertyQuery.getResultList();
ResultList rl = propertyNameList.getDelegate();
for (int i=0; i < rl.size(); i++) {
Object[] results = (Object[]) rl.get(i);
Long messageId = (Long) results[0];
Long propertyId = (Long) results[1];
em.getTransaction().begin();
Query update = em.createNativeQuery("UPDATE PROPERTY SET MESSAGE_ID = ? WHERE ID = ?");
update.setParameter(1, messageId);