Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » em.executeUpdate() DELETE always returning 1
em.executeUpdate() DELETE always returning 1 [message #639073] Mon, 15 November 2010 08:15 Go to next message
Ari Meyer is currently offline Ari MeyerFriend
Messages: 136
Registered: July 2009
Senior Member
Hi,

I'm using EclipseLink 2.1.1 and Oracle JDBC driver 11.1.0.7.0 against
Oracle 10.2.0.4.0.

I have a simple bulk delete:

<named-query name="deleteBudgetRsrcCurveForProjectId">
<query>
DELETE FROM BudgetRsrcCurve brc
WHERE brc.projectId = :projectId
AND brc.budgetType = :budgetType
</query>
</named-query>


invoked:
int numDeleted =
_entityManager.createNamedQuery("deleteBudgetRsrcCurveForProjectId ")
.setParameter("projectId", projectId)
.setParameter("budgetType", BudgetType.CERTIFIED)
.executeUpdate();
_logger.debug("deleted {} BUDGET_RSRC_CURVE record(s)", numDeleted);


log output:
[2010-11-14 23:18:52,750] DEBUG
mil.army.usace.p2.service.impl.BudgetServiceImpl deleted 1
BUDGET_RSRC_CURVE record(s)

It runs fine -- just deleted 485 records with my last successful test.
Only strange thing is that executeUpdate() always is returning 1. Even
for a case where there were no records to delete, it still returned 1.
Javadoc says:

int executeUpdate()

Execute an update or delete statement.

Returns:
the number of entities updated or deleted

Any ideas? I didn't find any reports of this on Google or the
EclipseLink forum.

Thanks,
Ari
Re: Query.executeUpdate() DELETE always returning 1 [message #639074 is a reply to message #639073] Mon, 15 November 2010 08:20 Go to previous messageGo to next message
Ari Meyer is currently offline Ari MeyerFriend
Messages: 136
Registered: July 2009
Senior Member
Sorry, I meant Query.executeUpdate(), not em.executeUpdate(). :-)
Ari

On 11/15/2010 12:15 AM, Ari Meyer wrote:
> Hi,
>
> I'm using EclipseLink 2.1.1 and Oracle JDBC driver 11.1.0.7.0 against
> Oracle 10.2.0.4.0.
>
> I have a simple bulk delete:
>
> <named-query name="deleteBudgetRsrcCurveForProjectId">
> <query>
> DELETE FROM BudgetRsrcCurve brc
> WHERE brc.projectId = :projectId
> AND brc.budgetType = :budgetType
> </query>
> </named-query>
>
>
> invoked:
> int numDeleted =
> _entityManager.createNamedQuery("deleteBudgetRsrcCurveForProjectId ")
> .setParameter("projectId", projectId)
> .setParameter("budgetType", BudgetType.CERTIFIED)
> .executeUpdate();
> _logger.debug("deleted {} BUDGET_RSRC_CURVE record(s)", numDeleted);
>
>
> log output:
> [2010-11-14 23:18:52,750] DEBUG
> mil.army.usace.p2.service.impl.BudgetServiceImpl deleted 1
> BUDGET_RSRC_CURVE record(s)
>
> It runs fine -- just deleted 485 records with my last successful test.
> Only strange thing is that executeUpdate() always is returning 1. Even
> for a case where there were no records to delete, it still returned 1.
> Javadoc says:
>
> int executeUpdate()
>
> Execute an update or delete statement.
>
> Returns:
> the number of entities updated or deleted
>
> Any ideas? I didn't find any reports of this on Google or the
> EclipseLink forum.
>
> Thanks,
> Ari
Re: Query.executeUpdate() DELETE always returning 1 [message #639173 is a reply to message #639074] Mon, 15 November 2010 14:10 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

When batch writing is enabled, EclipseLink will not immediately execute update queries - it instead adds them to the batch writing mechanism. The batch writing mechanism will be flushed on commit/flush (depending on the version, see bug 323370) or when there are enough statements of the same type to cause the batch to be executed.

Bug 266151 has been filed to add a way for the bach writing mechanism to be turned off for particular queries - allowing them to be executed outside of the batch and the correct count to be returned.

Best Regards,
Chris
Re: Query.executeUpdate() DELETE always returning 1 [message #639317 is a reply to message #639173] Tue, 16 November 2010 02:25 Go to previous message
Ari Meyer is currently offline Ari MeyerFriend
Messages: 136
Registered: July 2009
Senior Member
Thanks for the explanation!
Ari

On 11/15/2010 6:10 AM, Chris Delahunt wrote:
> Hello,
>
> When batch writing is enabled, EclipseLink will not immediately execute
> update queries - it instead adds them to the batch writing mechanism.
> The batch writing mechanism will be flushed on commit/flush (depending
> on the version, see bug 323370) or when there are enough statements of
> the same type to cause the batch to be executed.
> Bug 266151 has been filed to add a way for the bach writing mechanism to
> be turned off for particular queries - allowing them to be executed
> outside of the batch and the correct count to be returned.
> Best Regards,
> Chris
Previous Topic:JPA entities losing their id
Next Topic:Optimistic locking
Goto Forum:
  


Current Time: Tue Apr 23 15:27:55 GMT 2024

Powered by FUDForum. Page generated in 0.03813 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top