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

'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



Back to the top