openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plins...@gmail.com
Subject Re: Update by query and MySQL
Date Wed, 28 Nov 2007 14:36:41 GMT
Funny, there was a thread yesterday in which I mentioned the
inefficency that necessitates the subquery in your example.

It sounds like a bug to me.

-Patrick

On 11/28/07, Ognjen Blagojevic <ognjen@etf.bg.ac.yu> wrote:
> 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
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message