-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OptimisticLockException does not give any details if batch is active #1936
Conversation
Signed-off-by: Vaibhav Vishal <[email protected]>
Signed-off-by: Vaibhav Vishal <[email protected]>
Signed-off-by: Vaibhav Vishal <[email protected]>
What is Bugno35468915? |
I have created a new issue at #1938 for which this PR is being raised |
throw OptimisticLockException.batchStatementExecutionFailure(); | ||
Object object = null; | ||
DatabaseQuery query = this.previousCall.getQuery(); | ||
if (query instanceof UpdateObjectQuery) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid instanceof and use appropriate isUpdate*Query
method(s)
} | ||
Object object = null; | ||
DatabaseQuery query = this.previousCall.getQuery(); | ||
if (query instanceof UpdateObjectQuery) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dtto
...e/persistence/testing/tests/jpa/jpaadvancedproperties/OptimisticLockingBatchWritingTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Vaibhav Vishal <[email protected]>
return executeBatchRowCounts; | ||
} | ||
|
||
public void setExecuteBatchRowCounts(int[] rowCounts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new methods should have some documentation
Assert.assertTrue(e.getMessage(), | ||
e.getMessage().contains("One or more objects of class")); | ||
Assert.assertTrue(e.getMessage(), | ||
e.getMessage().contains("org.eclipse.persistence.testing.models.jpa.jpaadvancedproperties.Customer")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Customer.class.getName()
would be more friendly to possible refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I do not think the test will pass on Oracle DB - can you test it there and share resutls, please?
- new assertion can be probably added to existing test instead of adding whole new setup
I re-ran the tests using Oracle DB and it has passed successfully without any issues So let me know if we can keep the new testcase at eclipselink/jpa/eclipselink.jpa.testapps/jpa.test.jpaadvancedproperties/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpaadvancedproperties/OptimisticLockingBatchWritingTest.java or not |
Signed-off-by: Vaibhav Vishal <[email protected]>
When batch-writing is active and an OptimisticLockException appears then the message says "One or more objects cannot be updated because it has changed or been deleted since it was last read".
The above error message doesn't give details like which statement in batch execution has failed
So in the fix added parameters list which has failed for the SQL query during batch execution
Now the exception message will be as follows
"One or more objects of class org.eclipse.persistence.testing.tests.junit.optimisticlocking.Order with parameters list [[Order1-modified, 2, 1, 1]] cannot be updated for SQL query UPDATE ORDER_HEADER SET ORDERID = ?, TRANSACTIONCOUNT = ? WHERE ((ORDERKEY = ?) AND (TRANSACTIONCOUNT = ?)) because it has changed or been deleted since it was last read"
Added testcase at jpa/eclipselink.jpa.testapps/jpa.test.jpaadvancedproperties/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpaadvancedproperties/OptimisticLockingBatchWritingTest.java