em.executeUpdate() DELETE always returning 1 [message #639073] |
Mon, 15 November 2010 03:15  |
Eclipse User |
|
|
|
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 03:20   |
Eclipse User |
|
|
|
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 #639317 is a reply to message #639173] |
Mon, 15 November 2010 21:25  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04139 seconds