I try to do an update by query like this
em = emf.createEntityManager();
em.getTransaction().begin();
Query q = em.createQuery(
"UPDATE SifTipInstitucije o SET o.nazivEngleski='someText' WHERE
o.idTipInstitucije = 1");
int updated = q.executeUpdate();
em.getTransaction().commit();
em.close();
But it seems that OpenJPA (1.0.0) translates this into
UPDATE sif_tip_institucije
SET naziv_engleski = ?
WHERE id_tip_institucije IN
(SELECT DISTINCT t0.id_tip_institucije
FROM sif_tip_institucije t0
WHERE (t0.id_tip_institucije = ?))
[params=(String) someText, (long) 1]
Which is not legal MySQL query... It throws the exception:
You can't specify target table 'sif_tip_institucije' for update in FROM
clause.
Is this a bug? Should I log a JIRA?
Regards,
Ognjen