Skip to main content

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

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

 


Back to the top