java - JPA executeUpdate always returns 1 -


i'm having issue here executeupdate command returns value 1 though there's no record updated.

first retrieve several records, bit of calculation, , update status of of retrieved records.

the jpa update code:

private int executeupdatestatustosuccess(long id, query updatequery) {     updatequery.setparameter(1, getsysdatefromdb());     updatequery.setparameter(2, id);     int cnt = updatequery.executeupdate();     return cnt; // return 1 } 

the update query:

update product_param set status = 2, data_timestamp=? id = ? , status=-1 

note status column practically never valued < 0. i'm purposely adding condition here show though shouldn't have updated record, executeupdate() still returns value 1.

as additional note, there no update process anywhere between data retrieval , update. it's done within local environment.

any advice if i'm possibly missing here? or if there's configuration parameter need check?

edit: jpa i'm using eclipselink. database i'm using oracle 10g driver ojdbc5.jar.

in end have eclipselink jpa source code. system executes line

return integer.valueof(1); 

from codes inside basicexecutecall method of databaseaccessor class below:

if (isinbatchwritingmode(session)) {     // if there nothing returned , not using optimistic locking batch     //if storedprocedure in/out or out parameters not batch     //logic may weird must not batch if not using jdbc batchwriting , have parameters     // may want refactor day     if (dbcall.isnothingreturned() && (!dbcall.hasoptimisticlock() || getplatform().canbatchwritewithoptimisticlocking(dbcall) )          && (!dbcall.shouldbuildoutputrow()) && (getplatform().usesjdbcbatchwriting() || (!dbcall.hasparameters())) && (!dbcall.isloblocatorneeded())) {         // handle executing batched statements, or switching mechanisms if required         getactivebatchwritingmechanism().appendcall(session, dbcall);         //bug 4241441: passing 1 avoid optimistic lock exceptions since there            // no way know if succeeded on db @ point.         return integer.valueof(1);     } else {         getactivebatchwritingmechanism().executebatchedstatements(session);     } } 

one easy hack not using batch. i've tried turning off in persistence.xml , update returns expected value, 0.

<property name="eclipselink.jdbc.batch-writing" value="none" /> 

i'm expecting better solution 1 in situation.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -