Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] problem with update statement per native query

Hi Tom,
switching off batch writing works, but for us it fits better to stay on the session API now,
thank You, Markus

-----Ursprüngliche Nachricht-----
Von: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] Im Auftrag von Tom Ware
Gesendet: Dienstag, 21. Mai 2013 17:34
An: eclipselink-users@xxxxxxxxxxx
Betreff: Re: [eclipselink-users] problem with update statement per native query

'any chance you've got batch writing on?  Try the following hint:

  eclipselink.jdbc.batch-writing=false

On 21/05/2013 10:45 AM, Hahn, Markus wrote:
> Hello,
>
> I run into problems trying to use the return value of the native query created
> with the createNativeQuery method of EntityManager.
>
> If i try something like
>
> .
>
> Query query = this.getEntityManager().createNativeQuery("update foo set bar = 1
> where id = 21");
>
> int affectedRows = query.executeUpdate();
>
> .
>
> I get a value of 1 in affectedRows, even if there is no row with id 21 in table
> foo. No exception or something else.
>
> If I change to the session API for the same sql as in
>
> .
>
>        EntityManagerImpl em = (EntityManagerImpl)
> *this*.getEntityManager().getDelegate();
>
> *int* affectedRows =
>
> em.getDatabaseSession().executeNonSelectingCall(*new* SQLCall("update foo set
> bar = 1 where id = 21"));
>
> .
>
> it works as expected, that is I get 0 if there is no row with id 21.
>
> Is this a bug, or do I miss something?
>
> Regards, Markus
>
>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top