We have an enterprise product that uses EclipseLink JPA for persistence, using Oracle 11g as the underlying database. We are attempting also to support Microsoft SQL Server 2008R2, but have run into an intermittent but quite common error that makes it unusable. We are currently using EclipseLink 2.1.2 because it is the version supplied with Oracle WebLogic 10.3.3. Database updates sometimes throw an exception due to a deadlock reported by the database. We believe this is related to the granularity of locking – Oracle typically locks affected rows, but with SQL Server page or table locks may be used, leading to increased chance of deadlock.
When using Microsoft SQL Server through EclipseLink, there is no control on the granularity of database locks and no opportunity to retry an update after a deadlock. EclipseLink decides when to perform table locks, page locks, or individual row locks.
It is possible to supply hints to the SQL Server by including "WITH ROWLOCK" in the SQL statement
e.g UPDATE Products (WITH ROWLOCK) SET ProductCat = ‘Machine’ WHERE ProductSubCat = ‘Mac’
This may avoid the problem.
Are there any recommendations for configuring EclipseLink to work reliably with SQL Server, avoiding deadlocks or possibilities for customisation that would allow us to override the default behaviour?
Best regards,
David
------------------------
David Allen, Development Manager – Core Technology
1Spatial Group Limited
Telephone: +44 (0)1223 420414
Fax: +44 (0)1223 420044
david.allen@xxxxxxxxxxxx